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

Compiler warning #7572

Closed
saleyn opened this issue Aug 17, 2023 · 3 comments
Closed

Compiler warning #7572

saleyn opened this issue Aug 17, 2023 · 3 comments
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@saleyn
Copy link
Contributor

saleyn commented Aug 17, 2023

Describe the bug

In OTP-26 compilation of a NIF that includes <erl_nif.h> produces a warning:

$ cc -g -O3 -ansi -pedantic -Wall -Wextra -I../ -I ~/.asdf/installs/erlang/26.0/erts-14.0/include -fPIC -shared -o test.so test.c
In file included from test.c:4:
~/.asdf/installs/erlang/26.0/erts-14.0/include/erl_nif.h:192:21: warning: comma at end of enumerator list [-Wpedantic]
  192 |     ERL_NIF_UTF8 = 2,
      |                     ^

While the enum syntax permits the comma at the end of the last enum value, apparently the recent C compiler still emits the warning

File: erl_nif.h

typedef enum
{
    ERL_NIF_LATIN1 = 1,
    ERL_NIF_UTF8 = 2,                  // <--- here
}ErlNifCharEncoding;
@saleyn saleyn added the bug Issue is reported as a bug label Aug 17, 2023
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Aug 18, 2023
@attah
Copy link
Contributor

attah commented Aug 18, 2023

That's due to your -ansi flag (and being pedantic about that), not compilers in general.
Trailing comma was added in C99.
However; since C++ was slower at adding it (C++11?) it would make sense to not have it unless you already have somewhat high minimum C/C++ versions already elsewhere.

@saleyn
Copy link
Contributor Author

saleyn commented Aug 18, 2023

I believe it complains when using the -pedantic compiler flag. But combining -pedantic -std=c99 seems to quiet the warning.

@attah
Copy link
Contributor

attah commented Aug 18, 2023

Yes, pedantic ansi (aka c89) - as opposed to pedantic c99.

@saleyn saleyn closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants