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

Bug in C code when <nodecl,noinit> used together #146

Closed
stefanos82 opened this issue Oct 7, 2021 · 2 comments
Closed

Bug in C code when <nodecl,noinit> used together #146

stefanos82 opened this issue Oct 7, 2021 · 2 comments
Labels

Comments

@stefanos82
Copy link
Contributor

With the following code

require 'io'

local sts <nodecl,noinit>
do
  local sts = 1
  io.printf("inner local sts: %d\n", sts)
end
--io.printf("outer local sts: %d\n", sts)

I get an error in C code:

/home/stefanos/.cache/nelua/tmp.c: In function ‘nelua_GC_registerroots’:
/home/stefanos/.cache/nelua/tmp.c:1288:43: error: ‘tmp_sts’ undeclared (first use in this function)
 1288 |   nelua_GC_register((&nelua_gc), (void*)(&tmp_sts), 16U, 2U, (function_BQVUyrpMeDmmPHpu)NULL, (void*)NULL);
      |                                           ^~~~~~~
/home/stefanos/.cache/nelua/tmp.c:1288:43: note: each undeclared identifier is reported only once for each function it appears in
error: C compilation for '/home/stefanos/.cache/nelua/tmp' failed

shell returned 1

Press ENTER or type command to continue
@stefanos82 stefanos82 added the bug label Oct 7, 2021
@edubart
Copy link
Owner

edubart commented Oct 7, 2021

This is not a bug, this is a misuse of nodecl annotation. When you use that annotation the compiler expects that the variable gets declared in the C file, but this was not the case, so you get a C compiler error. Usually you use nodecl with cimport and have the variable declared in some C header.

@edubart edubart added the wontfix label Oct 7, 2021
@edubart edubart closed this as completed Oct 7, 2021
@edubart edubart removed the bug label Oct 7, 2021
@stefanos82
Copy link
Contributor Author

That's good to know; note taken. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants