Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

## is not implemented #506

Open
jyn514 opened this issue Aug 15, 2020 · 10 comments · May be fixed by #510
Open

## is not implemented #506

jyn514 opened this issue Aug 15, 2020 · 10 comments · May be fixed by #510
Labels
bug Something isn't working preprocessor Issue in the preprocessor (probably cycle detection)

Comments

@jyn514
Copy link
Owner

jyn514 commented Aug 15, 2020

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 jyn514 added bug Something isn't working preprocessor Issue in the preprocessor (probably cycle detection) labels Aug 15, 2020
@jyn514
Copy link
Owner Author

jyn514 commented Aug 15, 2020

This was broken in b7a16c2, cc @hdamron17

@jyn514
Copy link
Owner Author

jyn514 commented Aug 15, 2020

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

@jyn514
Copy link
Owner Author

jyn514 commented Aug 15, 2020

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
Copy link
Owner Author

jyn514 commented Aug 15, 2020

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 jyn514 changed the title Can no longer run hello world :( ## is not implemented Aug 15, 2020
@hdamron17
Copy link
Collaborator

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

@jyn514
Copy link
Owner Author

jyn514 commented Aug 15, 2020

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.

@hdamron17
Copy link
Collaborator

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

@hdamron17
Copy link
Collaborator

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

@jyn514
Copy link
Owner Author

jyn514 commented Aug 15, 2020

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.

@hdamron17 hdamron17 linked a pull request Aug 16, 2020 that will close this issue
@hdamron17
Copy link
Collaborator

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working preprocessor Issue in the preprocessor (probably cycle detection)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants