[cfe-dev] First steps with Clang; unknown builtins '__builtin_va_start' and '__builtin_va_end'

Francis Gagné fragag at hotmail.com
Mon Sep 13 17:48:22 PDT 2010


Hello,

I am currently working on some libraries written in C, for which I am writing documentation in an external XML document (using a custom schema), and I would like to use the Clang libraries to check that my documentation is up-to-date (i.e. that all functions/types/members are documented, and that all documented items are still present in the source code.

I started writing some code a bit at random, because the best source of documentation on Clang I could find is the Doxygen documentation, which is not really useful when I don't know what classes or functions I am supposed to use. This is my first experience with Clang, so I'm a bit lost. The following snippet has main0, my first attempt, and main, my second attempt.

http://pastebin.com/T494mbmD

Currently, both fail with the same errors:

c:/mingw/include/stdio.h:245:35: error: use of unknown builtin '__builtin_va_start'
  __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
                                  ^
c:/mingw/include/stdio.h:247:3: error: use of unknown builtin '__builtin_va_end'
  __builtin_va_end( __local_argv );
  ^
 
However, I can successfully compile the source file using clang:
 
K:\>C:\svn\llvm\Debug\bin\clang.exe -c K:\Sources\libasm\src\libasm.c -IK:\Sources\libasm\include -DLIBASM_BUILD_LIB
 
I'm using the latest LLVM and Clang from svn. I'm probably using classes or functions I shouldn't be using, so some assistance on how to prepare the different objects to successfully get an AST would be appreciated. I'm also wondering if I need to use the Sema library or not; all I need to do is check if every element (functions, structs, unions, enums, struct, union and enum members, global variables) in the source code has documentation. The library is composed of several source files, so I need a way of linking declarations/definitions together (from my understanding, 'entities' would be helpful here), and I need to know in which file the definition is (structs are defined in header files, so I need to know what header they were defined in; libasm.h or internal.h).
 
If I can't get this to work, I'll probably end up using the driver to output an XML file with the AST, which I'll compare to my documentation file. Collapsing duplicate declarations might be a bit of a hassle though.
 
Thanks in advance,
 
Francis Gagné
fragag at hotmail.com 		 	   		  



More information about the cfe-dev mailing list