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

redefinition of typedef ‘NIM_STATIC_ASSERT_AUX’ in x32 #17247

Closed
h4cnull opened this issue Mar 3, 2021 · 3 comments · Fixed by #23729
Closed

redefinition of typedef ‘NIM_STATIC_ASSERT_AUX’ in x32 #17247

h4cnull opened this issue Mar 3, 2021 · 3 comments · Fixed by #23729

Comments

@h4cnull
Copy link

h4cnull commented Mar 3, 2021

I try to use musl-gcc build a 32bit file。
system: centos6.8 i386
command: nim --gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc --passL:-static -d:release -d:danger -d:strip --opt:size c xxx.nim
error out:

Hint: used config file '/opt/nim/config/nim.cfg' [Conf]
Hint: used config file '/opt/nim/config/config.nims' [Conf]
...............................................
Hint: musl-gcc -c -w -fmax-errors=3 -Os -fno-ident -I/opt/nim/lib -I/root -o /root/.cache/nim/xxx_r/stdlib_assertions.nim.c.o /root/.cache/nim/xxx_r/stdlib_assertions.nim.c [Exec]
In file included from /root/.cache/nim/xxx_r/stdlib_assertions.nim.c:12:
/opt/nim/lib/nimbase.h:542: error: redefinition of typedef ‘NIM_STATIC_ASSERT_AUX’
/opt/nim/lib/nimbase.h:323: note: previous declaration of ‘NIM_STATIC_ASSERT_AUX’ was here
Error: execution of an external program failed: 'musl-gcc -c -w -fmax-errors=3 -Os -fno-ident -I/opt/nim/lib -I/root -o /root/.cache/nim/xxx_r/stdlib_assertions.nim.c.o /root/.cache/nim/xxx_r/stdlib_assertions.nim.c'

@timotheecour
Copy link
Member

@h4cnull PR welcome

@h4cnull
Copy link
Author

h4cnull commented Mar 5, 2021

I back up lib/nimbash.h and add comment these lines,error fixed。
274 //#else
275 //#define NIM_STATIC_ASSERT(x, msg) typedef int NIM_STATIC_ASSERT_AUX[(x) ? 1 : -1];

323 //NIM_STATIC_ASSERT(sizeof(NIM_BOOL) == 1, ""); // check whether really needed
542 //NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 , "");

@FedericoCeratto
Copy link
Member

I'm able to reproduce the issue by using gcc 4.1 or 4.2:

./bin/nim c --gcc.exe:gcc-4.2 koch.nim
[trimmed]
.........................................................
CC: stdlib_assertions.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_parseutils.nim
CC: stdlib_math.nim
In file included from /home/fede/.cache/nim/koch_d/stdlib_assertions.nim.c:8:
/home/fede/projects/Nim/lib/nimbase.h:546: error: redefinition of typedef ‘NIM_STATIC_ASSERT_AUX’
/home/fede/projects/Nim/lib/nimbase.h:327: error: previous declaration of ‘NIM_STATIC_ASSERT_AUX’ was here
In file included from /home/fede/.cache/nim/koch_d/stdlib_io.nim.c:8:
/home/fede/projects/Nim/lib/nimbase.h:546: error: redefinition of typedef ‘NIM_STATIC_ASSERT_AUX’
/home/fede/projects/Nim/lib/nimbase.h:327: error: previous declaration of ‘NIM_STATIC_ASSERT_AUX’ was here
CC: stdlib_unicode.nim
[trimmed]

fakuivan added a commit to fakuivan/Nim that referenced this issue Jun 17, 2024
fixes nim-lang#17247

This generates a new NIM_STATIC_ASSERT_AUX variable
for each line that NIM_STATIC_ASSERT is called from.

While this can solve all existing issues in the current
code base, this method is not effective for multiple
asserts on a single line.
@Araq Araq closed this as completed in 33f5ce8 Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants