Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Last active January 4, 2020 11:10
Show Gist options
  • Save jstaursky/63bfe0d87ce80c81887fcba2575368bb to your computer and use it in GitHub Desktop.
Save jstaursky/63bfe0d87ce80c81887fcba2575368bb to your computer and use it in GitHub Desktop.
How to view gcc/g++ macros, search-paths, ...

How to view __cplusplus macro definition

g++ -x c++ -std=c++17 -dM -E - </dev/null | grep __cplusplus

useful for optioning c++17 features like so,

#if __cplusplus >= 201703L
        auto fsize = filesystem::file_size(argv[1]);
#else
        struct stat filestatus;
        stat (argv[1], &filestatus);
        auto fsize = filestatus.st_size;
#endif

How to view compiler include’s search paths

gcc -v -E - < /dev/null 2>&1 | awk '/^#include/,/^End of search/' | grep '^ '.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment