[aspectc-user] extern "C" parsing problem.

Olaf Spinczyk os at aspectc.org
Wed Apr 20 17:35:02 CEST 2011


Hi!

In order to narrow down the problem you can do two things:

1. Run the g++ preprocessor (with -E) and store its output. Then check 
whether ag++ can compile the preprocessed code.

I would expect this to be problem of the ac++ preprocessor. Therefore, 
it is possible that this works. If it does not and g++ is able to 
compile the preprocessed code, send it to me and I'll do the rest. If it 
does, continue with 2.

2. Download 
ftp://akut.aspectc.org/Debian4.0/i386/acpp_Debian4.0_i386_ac97_ag21_puma593_build.402.tar.bz2, 
unpack, and execute the following commands:

ag++ --c_compiler i386-elf-g++ --gen_config

=> generates a parser configuration file 'puma.config'

./parser --dump-cpp --config puma.config --lang-c++ <include paths etc> 
main.cpp

=> This should run the ac++ preprocessor.

You can compare the result with the output of the g++ preprocessor.

Let me know what the result is. Better use a direct mail. There is no 
need to bother other people on this list with too many details.

Cheers,

Olaf


On 04/20/2011 04:03 PM, Guilherme . wrote:
> Hi!
>
> I have a header file "stdio.h" that has many lines in the format
>
> __externC argument fn(params) __THROW;
>
> __externC expands to extern  "C" (as expected) and __THROW to throw() 
> but on some lines i get the message:
>
> ecos/install/include/cyg/libc/stdio/stdio.h:155: error: invalid 
> declaration near token `"C"'
>
> This is weird since for some lines there are no problem and on other 
> it complains...
>
> Here is what i mean:
>
> Excerpt from stdio.h
>
> 145 __externC FILE *
> 146 fopen( const char * /* filename */, const char * /* mode */ ) __THROW;
> 147
> 148 __externC FILE *
> 149 freopen( const char * /* filename */, const char * /* mode */,
> 150          FILE * /* stream */ ) __THROW;
> 151
> 152 __externC void
> 153 setbuf( FILE * /* stream */, char * /* buffer */ ) __THROW;
> 154
> 155 __externC int
> 156 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */,
> 157          size_t /* size */ ) __THROW;
> 158
> 159 
> //========================================================================
> 160
> 161 // ISO C89 7.9.6 Formatted input/output functions
> 162
> 163 __externC int
> 164 fprintf( FILE * /* stream */, const char * /* format */, ... ) __THROW
> 165     CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
> 166
> 167 __externC int
> 168 fscanf( FILE * /* stream */, const char * /* format */, ... ) __THROW
> 169     CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
> 170
> 171 __externC int
> 172 printf( const char * /* format */, ... ) __THROW
> 173     CYGBLD_ATTRIB_PRINTF_FORMAT(1, 2);
> 174
> 175 __externC int
> 176 scanf( const char * /* format */, ... ) __THROW
> 177     CYGBLD_ATTRIB_SCANF_FORMAT(1, 2);
> 178
> 179 __externC int
> 180 sprintf( char * /* str */, const char * /* format */, ... ) __THROW
> 181     CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
> 182
> 183 __externC int
> 184 sscanf( const char * /* str */, const char * /* format */, ... ) 
> __THROW
> 185     CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
> 186
> 187 __externC int
> 188 vfprintf( FILE * /* stream */, const char * /* format */,
> 189           va_list /* args */ ) __THROW 
> CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
> 190
>
> and the error message from ac++:
>
> ag++ -v9 --c_compiler i386-elf-g++   -o build/main.o main.cpp -c 
> -I./ecos/install/include -I. 
> -I/opt/sigubufo/branch/tools/gnutools/i386-elf/lib/gcc-lib/i386-elf/3.2.1/include/ 
> -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Woverloaded-virtual 
> -Wno-write-strings -g -O2 -ffunction-sections -fdata-sections 
> -fno-rtti -fno-exceptions -D_KERNEL
> *
> *
> * AG++ Configuration:
> *   Aspect C++ weaver:  ac++
> *   C++ compiler:       i386-elf-g++
> *   Files:               main.cpp
> *   Options (G++):       -v -o "build/main.o"  -I "."  -c -I 
> "./ecos/install/include"  -I "."  -I 
> "/opt/sigubufo/branch/tools/gnutools/i386-elf/lib/gcc-lib/i386-elf/3.2.1/include/"  
> -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Woverloaded-virtual 
> -Wno-write-strings -g -O2 -ffunction-sections -fdata-sections 
> -fno-rtti -fno-exceptions -D "_KERNEL"
> *   Options (AC++):      -v9 -I "./ecos/install/include"  -I "."  -I 
> "/opt/sigubufo/branch/tools/gnutools/i386-elf/lib/gcc-lib/i386-elf/3.2.1/include/"  
> -D "_KERNEL"  -p.
> *   Options (total):     -v9 -v -o "build/main.o"  main.cpp -I "."  -c 
> -I "./ecos/install/include"  -I "."  -I 
> "/opt/sigubufo/branch/tools/gnutools/i386-elf/lib/gcc-lib/i386-elf/3.2.1/include/"  
> -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Woverloaded-virtual 
> -Wno-write-strings -g -O2 -ffunction-sections -fdata-sections 
> -fno-rtti -fno-exceptions -D "_KERNEL"  -p.
> *   PumaConfig: 1 Weave: 1 Compile: 1 Link: 0
> *
> *
> * Generating Puma configuration file
>   - Parsing output of g++ compiler
>   - Executing: "i386-elf-g++"  -Wall -Wpointer-arith 
> -Wstrict-prototypes -Wundef -Woverloaded-virtual -Wno-write-strings -g 
> -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -E 
> -dM -v -x c++ "/dev/null" 2>/tmp/agxx_stderrC5cftH 
> 1>/tmp/agxx_stdoutEn4tHb
>   - Exit: Success
>   - removing temporary file: /tmp/agxx_stdoutEn4tHb
>   - removing temporary file: /tmp/agxx_stderrC5cftH
>   - Writing puma configuration file '/tmp/agxx_pcfg2cXLVF'
> * Weaving
>   - Executing: "ac++" --config "/tmp/agxx_pcfg2cXLVF"  -v9 -I 
> "./ecos/install/include"  -I "."  -I 
> "/opt/sigubufo/branch/tools/gnutools/i386-elf/lib/gcc-lib/i386-elf/3.2.1/include/"  
> -D "_KERNEL"  -p. -c "main.cpp" -o "/tmp/main.cpp_agxx_2Dhk1d"
> * Running ac++ 1.0
> * Handling Translation Unit `main.cpp'.
>   - Path "main.cpp"
>   - Inserting namespace AC
>   - Parsing ...
> ecos/install/include/cyg/libc/stdio/stdio.h:155: error: invalid 
> declaration near token `"C"'
> ecos/install/include/cyg/libc/stdio/stdio.h:187: error: invalid 
> declaration near token `"C"'
> ecos/install/include/cyg/libc/stdio/stdio.h:191: error: invalid 
> declaration near token `"C"'
> ecos/install/include/cyg/libc/stdio/stdio.h:195: error: invalid 
> declaration near token `"C"'
> ecos/install/include/cyg/libc/stdio/stdio.h:247: error: invalid 
> declaration near token `"C"'
>
> as one can see he does only complain for some of the lines (until line 
> 155 he is happy about all those __externC), not all...
>
> Is there a way i can further narrow down this problem?
>
> Best regards,
> Guilherme
>
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20110420/cf71ccfa/attachment.html>


More information about the aspectc-user mailing list