How to parse C files with stdint.h types
See original GitHub issueI 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:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Workaround for types defined in archives but not used during import/parsing:
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:
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:
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.
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.