Menu

#2490 Macro invocation split over many files

open
nobody
None
Preprocessor
5
2023-07-29
2016-04-12
No

Using sdcc 3.5.5 #9495, I get

test.c:12: syntax error: token -> ')' ; column 3

However, according to the C comittee, it is valid code (see DR 482).

Philipp

3 Attachments

Discussion

  • Ben Shi

    Ben Shi - 2016-04-13

    Even gcc gave an error with your code

    Ben@Ben-PC /cygdrive/d/sdcc/qwe/qwe
    $ gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/lto-wrapper.exe
    Target: x86_64-pc-cygwin
    Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-4.9.2-3.x86_64/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-4.9.2-3.x86_64/src/gcc-4.9.2 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id
    Thread model: posix
    gcc version 4.9.2 (GCC)
    
    Ben@Ben-PC /cygdrive/d/sdcc/qwe/qwe
    $ gcc test.c -c
    In file included from file1.h:1:0,
                     from test.c:11:
    file2.h: In function main:
    file2.h:3:0: error: unterminated argument list invoking macro "assert"
    
     ^
    file2.h:1:1: error: assert undeclared (first use in this function)
     assert(
     ^
    file2.h:1:1: note: each undeclared identifier is reported only once for each function it appears in
    test.c:12:3: error: expected ; before ) token
       );                    /* end of assert() */
       ^
    test.c:12:3: error: expected statement before ) token
    
     
  • Ben Shi

    Ben Shi - 2016-04-13

    It is complained by the cpp,

    Ben@Ben-PC /cygdrive/d/sdcc/qwe/qwe
    $ gcc -E test.c > /dev/null
    In file included from file1.h:1:0,
                     from test.c:11:
    file2.h:3:0: error: unterminated argument list invoking macro "assert"
    
     ^
    
    Ben@Ben-PC /cygdrive/d/sdcc/qwe/qwe
    $ sdcc -E test.c > /dev/null
    In file included from file1.h:1,
                     from test.c:11:
    file2.h:3:1: error: unterminated argument list invoking macro "assert"
    
     
  • Ben Shi

    Ben Shi - 2016-04-13
    • Category: other --> Preprocessor
     
  • Ben Shi

    Ben Shi - 2016-04-13

    A better way might be we wait for gcc fix it and then merge a newer cpp.

     
  • Sergey Belyashov

    gcc-9.3.0 cannot compile it.

     
  • Philipp Klaus Krause

    This bug is still present in sdcc from current svn (and in GCC12.2 - clang 15.0.6 can compile it)

     
  • Philipp Klaus Krause

    Still the same situation today: clang accepts it but neither SDCC nor GCC do.

     

Log in to post a comment.

Auth0 Logo