preprocessor/6781: Creating header-names is not possible

loewis@informatik.hu-berlin.de loewis@informatik.hu-berlin.de
Thu May 23 03:26:00 GMT 2002


>Number:         6781
>Category:       preprocessor
>Synopsis:       Creating header-names is not possible
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu May 23 03:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1
>Organization:
HUB
>Environment:
System: SunOS paros 5.9 Beta_Refresh sun4u sparc SUNW,Sun-Blade-1000
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../configure --host=sparc-sun-solaris2.8 --enable-shared --enable-threads --with-cpu=v8 --with-gnu-ld --with-gnu-as --enable-version-specific-runtime-libs
>Description:
	The code

#define inc2(a,b) <##a##.##b##>
#define INC(X) inc2(X,h)
#include INC(stdio)

int main()
{
  printf("Hallo");
}

	first gives a warning, then reports

	stdio: No such file or directory

The intent of this code is to create a header-name token (2.8)
through token pasting. In an pedantic interpretation, this invokes
undefined behaviour, since it creates intermediate tokens which are
invalid preprocessing tokens.

GCC should support this code as an extension (performing an #include
of stdio.h), and only warn about this problem when pedantic (since it
is undefined behaviour, no diagnostics is required by the standard).
More specifically, it normally should only emit the warning if 
interpreting the full ## sequence produces an invalid token.

Havin this extension is desirable, because
a) nearly every other compiler supports it (even though just because
   the compilers fail to notice the problem);
b) this is the best approach to deal with portability of CORBA applications,
   where different IDL compilers emit differently named header files.
    

>How-To-Repeat:
	Compile the included program.
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list