This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: undefined declaration in pre-processed generated C file

In fact, I'm working on the development of a concept validation tools, based on the source code (static approach).
I use a parser to read the pre-processed files, but I've found problem due to the __builtin_* declarations.

I though about grep action on preprocessed file, but this solution isn't completely agree with some cases that I encountered: I have the case where this type is used (such as in vsnprintf function).
But I think to have another solution that will work with my problematic.

I need to realize more tests to see all special cases like builtin case.

Thank you for your fast answer. It will help me for my development.



-----Message d'origine-----
De?: Dave Korn [] 
Envoyé?: jeudi 30 mars 2006 15:14
Objet?: RE: undefined declaration in pre-processed generated C file

On 30 March 2006 13:52, GALLEGGIANTI Bruno wrote:

> typedef __builtin_va_list __gnu_va_list;
> My problem is that __builtin_va_list is never declared/defined in the
> pre-processed file. I've no warning about that (-Wall option)
> Following this behaviour, I have 3 questions:
> 1) How does gcc compiler resolve this typedef (before link stage) ?

  It's magic.  Gcc knows about all builtins automatically because they are
implemented in code inside the compiler.  For more details about how stdargs
work, run "info gccint" and browse the section about "Implementing the Varargs
Macros".  If you're really curious, the __builtin_va_list struct is (IIRC)
generally the same struct as whatever the backend defines as CUMULATIVE_ARGS -
read the info page about "Passing Arguments in Registers".

> 2) Is there a gcc option that can remove this type of definition in
> pre-processed files? I think it's not possible before link stage.

  Would "grep -v 'typedef __builtin' <sourcefile.i >newsourcefile.i" do the
job you're after?

  The real question 
> 3) Is there a possibility to obtain pre-processed C source file after
> link phase (without optimization)?

  Nope, that doesn't make sense; first, by link time, the C has already been
turned into assembler long ago; second, optimisation is not applied to the C
source but to the internal representation.

  What are you /actually/ trying to do?

Can't think of a witty .sigline today....

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]