'How can I list the functions that were made available via a #include in C?
what is the substitute for something like this,
dir(int)
in C? when I include something like,
#include <string.h>
then I would like to see what is being included.
Solution 1:[1]
C does not have any introspective feature analogous to Python's dir(). It also does not have an object model at all like Python's, which would be necessary to make that sensible. Especially, it does not have anything along the lines of packages- or modules-as-objects, which is the only way that an analogue of dir() could be useful for inspecting header contents.
The C programmer generally approaches the issue from exactly the opposite direction: (1) what functions do I need? (2) what headers provide their declarations, and what additional libraries, if any, need to be linked to get their implementations?
Solution 2:[2]
If you are using GCC to compile your code you can use:
gcc -E NAMEOFFILE.c
Which will give you the file after its run through the preprocessor.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Bollinger |
| Solution 2 | Noah Lewis |
