saltwater icon indicating copy to clipboard operation
saltwater copied to clipboard

## is not implemented

Open jyn514 opened this issue 4 years ago • 10 comments

Expected behavior

cargo run tests/runner-tests/hello_world.c works on linux platforms.

Code

#include<stdio.h>

int main() {
    puts("Hello, world!");
}
bits/libc-header-start.h:56:4 error: invalid macro: trailing tokens in `#if` expression
#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X)
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

jyn514 avatar Aug 15 '20 04:08 jyn514

This was broken in b7a16c258d0db41ee67e7a7b8daf9295ca44e7cf, cc @hdamron17

jyn514 avatar Aug 15 '20 04:08 jyn514

$ rg '#define __GLIBC_USE' /usr/include/
/usr/include/features.h
179:#define __GLIBC_USE(F)	__GLIBC_USE_ ## F

jyn514 avatar Aug 15 '20 04:08 jyn514

Minimal reproduction:

#define __GLIBC_USE(F)	__GLIBC_USE_ ## F
# define __GLIBC_USE_IEC_60559_TYPES_EXT 1 
# define __GLIBC_USE_ISOC2X 1
#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X)
	int main() {}
#endif
<stdin>:4:4 error: invalid macro: trailing tokens in `#if` expression
#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X)
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<stdin>:6:2 error: invalid macro: #endif without #if
#endif
 ^^^^^

jyn514 avatar Aug 15 '20 05:08 jyn514

I think this is just that ## isn't implemented and the error is slightly different than before: http://port70.net/~nsz/c/c11/n1570.html#6.10.3.3

jyn514 avatar Aug 15 '20 05:08 jyn514

It passed the tests..? I'm confused how if it depended on ##

hdamron17 avatar Aug 15 '20 14:08 hdamron17

Well, hello_world.c is platform dependent. So glibc on my machine is probably different from glibc on travis. I just haven't tried to run the tests since you merged that fix.

jyn514 avatar Aug 15 '20 14:08 jyn514

Hmm. I thought I ran it on my Ubuntu machine but maybe not. Or it could be different there too.

hdamron17 avatar Aug 15 '20 17:08 hdamron17

I don't think ## will be too hard to implement. But maybe that's a problem for after you finish separating out the preprocessor.

hdamron17 avatar Aug 15 '20 17:08 hdamron17

I don't think ## will be too hard to implement. But maybe that's a problem for after you finish separating out the preprocessor.

Let's not wait for me to separate the preprocessor 😅 we'll be here a while. I don't expect ## to make it any harder to separate than it already is.

jyn514 avatar Aug 15 '20 17:08 jyn514

This is going to be a lot harder than I originally thought because we're dealing with tokens not plain strings and the token type can change in concatenation. E.g. 5 ## e5 (int, id) -> 5e5 (float).

hdamron17 avatar Aug 16 '20 18:08 hdamron17