question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to parse C files with stdint.h types

See original GitHub issue

I have a C file that includes structs whose members are of one of the stdint.h types (e.g. uint8_t, int32_t, int_fast8_t, etc). When I add this file to the “Source files to parse”, and hit “Parse to Program”, I get the following error:

C Parser: Encountered errors during parse.
    in <file> near line -5
    near token: null
    Last Valid Datatype: foo
    Check around CParserPlugin.out around line: 96

CParserPlugin.out is:

95  struct pa_channel_map {
96      uint8_t channels;
97      pa_channel_position_t map[32];
98  };

How do I parse this file without manually defining the stdint types?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
therealchjonescommented, Mar 31, 2021

Workaround for types defined in archives but not used during import/parsing:

  1. In the data type manager, filter then right-click on the needed files. (In the case of many programs that need only “standard” definitions like the above, types.h and stdint.h will suffice.) Export the C headers of the file: dtm-export

  2. In the C parser dialog, empty all files and options (the “eraser” icon). Add the newly exported headers as well as the header for the program you’re analyzing: parse-dialog

Certainly further customization may be needed for appropriate choices of archive files to export-then-import or other issues, but this solves the specific case of the OP and many other similar ones.

0reactions
emteerecommented, Oct 13, 2022

The Cparser has had some refactoring, bug fixes, and better error reporting completed in an upcoming change. Types that are unsatisfied from parsing will be looked up in any open archives. In addition any types that are equivalent from any open archive with a parsed data type will use the data type from the archive. After parsing you can disconnect the data types from the dependent archive if you no longer want to synchronize with dependent archive. There are also three options on the warning dialog to Use Open Archives, Don’t Use Open Archives, and Cancel.

This was always a planned change, but there needed to be some refactoring and cleanup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C Programming/stdint.h - Wikibooks
h defines limits of integer types capable of holding object pointers such as UINTPTR_MAX , the value of which depends on the processor...
Read more >
Best practice: Use of stdint types in a header file - Stack Overflow
If you use types from stdint.h in your header, you really should include stdint.h in that header. It is generally preferred to include...
Read more >
The C stdint.h Header File - YouTube
A discussion of the stdint. h file and why we need it.Music used in this video (Vibe Tracks, Alternate) was downloaded from the...
Read more >
11 Standard integers (stdint.h) and mixing integer types
This lesson is about the fixed-width integer types ( stdint. h ), endianness, integer promotion, and mixing integer data types in expressions.
Read more >
<stdint.h>
It shall also define macros that specify limits of integer types corresponding to types defined in other standard headers. Note: The "width" of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found