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:

  1. from project itself,in source file(this easiest,because can find tool)
  2. from header file of 3rd lib ,we can grep it
  3. from c/c++ standard header file(where in linux?)
  4. from os (where in linux?)
  5. automatically generated configure tool(it bitter,i have no idea)
  6. from compiler tool gcc/g++,or in makefile can define macro

i have question consult:

  1. how differentiate them between os defined , gcc/g++ defined , configure tool generated macros? have characteristic respectively?
  2. how find source of defined os or standard c or compiler? e.g.,using grep or find utilities
  3. 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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -