Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen preprocessor directive placed after struct declaration #11691

Closed
muiroc opened this issue Jul 8, 2019 · 2 comments

Comments

@muiroc
Copy link

commented Jul 8, 2019

When compiling with --debugger:native this line gets generated:
(note the ifndef after the comma)

struct tySequence_sM4lkSb7zS6F7OVMvW9cffQ {  NI len; tySequence_sM4lkSb7zS6F7OVMvW9cffQ_Content* p;};#ifndef tySequence_uB9b75OUPRENsBAu4AnoePA_Content_PP

causing a compile error:

error C2014: preprocessor command must start as first nonwhite space
fatal error C1020: unexpected #endif

Possible Solution

temporarly I tried changing this

"};$n", [result])

to

          "};$N", [result])

seeing that by enabling debugger:native this options are set

conf.options = conf.options + {optLineDir} - {optEndb}

optLineDir is setted and then used in
if optLineDir notin `m`.config.options:

For the record, there are other newline related differencies:
without debugger:native

struct tyObject_Pixels_d9cAAoDxyHitNWVHpUYE8JA {
tyEnum_PixelFormat_pFNxyFdipagghtQvPb8fig format;
tyObject_Extent3_8mqbEC9c9ba9a2dnSHRkGEI9aw dim;
tySequence_6H5Oh5UUvVCLiakt9aTwtUQ bytes;
};

with debugger:native

struct tyObject_Pixels_d9cAAoDxyHitNWVHpUYE8JA {tyEnum_PixelFormat_pFNxyFdipagghtQvPb8fig format;
tyObject_Extent3_8mqbEC9c9ba9a2dnSHRkGEI9aw dim;
tySequence_6H5Oh5UUvVCLiakt9aTwtUQ bytes;
};

and some "two structs on a line"

struct tySequence_uB9b75OUPRENsBAu4AnoePA {  NI len; tySequence_uB9b75OUPRENsBAu4AnoePA_Content* p;};struct Exception {  RootObj Sup;Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence_uB9b75OUPRENsBAu4AnoePA trace;
NU raiseId;
Exception* up;
};

Additional Information

--newruntime
devel

git hash: 655cb084610cde787f9b78360b96b3b97541112b
active boot switches: -d:release

@mratsim mratsim added the Codegen label Jul 8, 2019

@mratsim

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2019

Does it happen without the --newruntime switch?

@muiroc

This comment has been minimized.

Copy link
Author

commented Jul 9, 2019

@mratsim
Just tried and without --newruntime it compiles fine

Forgot to say that the generated file where this happens is stdlib_system.nim.c

Without newruntime I see there are neither any "ifndef/define/endifs" blocks nor structs with tySequence_stuff_Content

I tried creating a small repro project, but it compiles fine even with newruntime, I can't seem to trigger that declarations ordering...

@Araq Araq closed this in 6663dbb Jul 10, 2019

narimiran added a commit that referenced this issue Jul 15, 2019

fixes #11691
(cherry picked from commit 6663dbb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.