c++ - how to find the source of some macros -
there many places defining macro.when macro defined in our own project us,the easy find definition position them. when try learn famous open source project,i pestered question:where find source of macros,if can not it's definition,i won't understand of them (e.g. of them can guessed name). example,some statement apache:
#if defined(__osf__) && defined(__alpha), #elif defined(__nsig)
as knowledge,i know there possible originating place macro:
- from project itself,in source file(this easiest,because can find tool)
- from header file of 3rd lib ,we can grep it
- from c/c++ standard header file(where in linux?)
- from os (where in linux?)
- automatically generated configure tool(it bitter,i have no idea)
- from compiler tool gcc/g++,or in makefile can define macro
i have question consult:
- how differentiate them between os defined , gcc/g++ defined , configure tool generated macros? have characteristic respectively?
- how find source of defined os or standard c or compiler? e.g.,using
grep
orfind
utilities - what mean if 1 macro such
__strange___
can not find combing whole machine (cd /;grep __strange___ -r
)?
thanks telling principle , method distinguish them , ,to find source of them!
a simple, quick way find out macro has been defined redefine macro , check compiler's warning/error message.
#include <windows.h> #define min(a,b) nonsense mintest.cpp(3) : warning c4005: 'min' : macro redefinition c:\programme\microsoft sdks\windows\v6.0a\include\windef.h(194) : see previous definition of 'min'
Comments
Post a Comment