Why does prevent the use of âsi_â as prefix for the name of some variables?
Clash Royale CLAN TAG#URR8PPP
up vote
10
down vote
favorite
I have been debugging a strange compilation error that I was getting inside my code, and I ended up finding out that I cannot use the prefix si_
for some variable names (of any type) if <signal.h>
is included.
Here is a very simple source code example that reproduces the issue:
#include <signal.h>
int main(void)
int si_value = 0;
return 0;
If I try to compile this with the GNU C Compiler gcc
, I get the following error:
> gcc example.c
In file included from /usr/include/signal.h:57:0,
from example.c:2:
example.c: In function âÂÂmainâÂÂ:
example.c:6:9: error: expected âÂÂ=âÂÂ, âÂÂ,âÂÂ, âÂÂ;âÂÂ, âÂÂasmâ or âÂÂ__attribute__â before âÂÂ.â token
int si_value = 0;
^
example.c:6:9: error: expected expression before âÂÂ.â token
Nonetheless, if I use another name such as si_value2
, the error doesn't show up. As a reference, I'm using GCC v7.3.0 on Ubuntu Mate 18.04.1 LTS. The same problem is observed with g++
.
I suppose that this behaviour is due to some macro definition inside the <signal.h>
header, but after going through it briefly, I couldn't seem to find anything really related.
I honestly can fix it by just using another name. However, my concern is: how could I elegantly avoid this type of issue in the future?
Update: As @F.X. has suggested, using gcc -E example.c
shows that the variable name is expanded (hence, the error):
...
int
# 6 "example.c" 3 4
_sifields._rt.si_sigval
# 6 "example.c"
= 0;
...
c++ c linux
 |Â
show 7 more comments
up vote
10
down vote
favorite
I have been debugging a strange compilation error that I was getting inside my code, and I ended up finding out that I cannot use the prefix si_
for some variable names (of any type) if <signal.h>
is included.
Here is a very simple source code example that reproduces the issue:
#include <signal.h>
int main(void)
int si_value = 0;
return 0;
If I try to compile this with the GNU C Compiler gcc
, I get the following error:
> gcc example.c
In file included from /usr/include/signal.h:57:0,
from example.c:2:
example.c: In function âÂÂmainâÂÂ:
example.c:6:9: error: expected âÂÂ=âÂÂ, âÂÂ,âÂÂ, âÂÂ;âÂÂ, âÂÂasmâ or âÂÂ__attribute__â before âÂÂ.â token
int si_value = 0;
^
example.c:6:9: error: expected expression before âÂÂ.â token
Nonetheless, if I use another name such as si_value2
, the error doesn't show up. As a reference, I'm using GCC v7.3.0 on Ubuntu Mate 18.04.1 LTS. The same problem is observed with g++
.
I suppose that this behaviour is due to some macro definition inside the <signal.h>
header, but after going through it briefly, I couldn't seem to find anything really related.
I honestly can fix it by just using another name. However, my concern is: how could I elegantly avoid this type of issue in the future?
Update: As @F.X. has suggested, using gcc -E example.c
shows that the variable name is expanded (hence, the error):
...
int
# 6 "example.c" 3 4
_sifields._rt.si_sigval
# 6 "example.c"
= 0;
...
c++ c linux
4
Can you look at the output ofgcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.
â F.X.
2 hours ago
4
Is it just the namesi_value
? Smells like a macro is getting substituted into your code. What about something likesi_vy1ghad563nvy43wd
?
â alter igel
2 hours ago
2
@alterigel sorry,si_vy1ghad563nvy43wd
is also a reserved keyword.
â Jean-François Fabre
2 hours ago
2
@Jean-FrançoisFabre sorry,si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see howsi_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.
â Andrew Henle
2 hours ago
3
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago
 |Â
show 7 more comments
up vote
10
down vote
favorite
up vote
10
down vote
favorite
I have been debugging a strange compilation error that I was getting inside my code, and I ended up finding out that I cannot use the prefix si_
for some variable names (of any type) if <signal.h>
is included.
Here is a very simple source code example that reproduces the issue:
#include <signal.h>
int main(void)
int si_value = 0;
return 0;
If I try to compile this with the GNU C Compiler gcc
, I get the following error:
> gcc example.c
In file included from /usr/include/signal.h:57:0,
from example.c:2:
example.c: In function âÂÂmainâÂÂ:
example.c:6:9: error: expected âÂÂ=âÂÂ, âÂÂ,âÂÂ, âÂÂ;âÂÂ, âÂÂasmâ or âÂÂ__attribute__â before âÂÂ.â token
int si_value = 0;
^
example.c:6:9: error: expected expression before âÂÂ.â token
Nonetheless, if I use another name such as si_value2
, the error doesn't show up. As a reference, I'm using GCC v7.3.0 on Ubuntu Mate 18.04.1 LTS. The same problem is observed with g++
.
I suppose that this behaviour is due to some macro definition inside the <signal.h>
header, but after going through it briefly, I couldn't seem to find anything really related.
I honestly can fix it by just using another name. However, my concern is: how could I elegantly avoid this type of issue in the future?
Update: As @F.X. has suggested, using gcc -E example.c
shows that the variable name is expanded (hence, the error):
...
int
# 6 "example.c" 3 4
_sifields._rt.si_sigval
# 6 "example.c"
= 0;
...
c++ c linux
I have been debugging a strange compilation error that I was getting inside my code, and I ended up finding out that I cannot use the prefix si_
for some variable names (of any type) if <signal.h>
is included.
Here is a very simple source code example that reproduces the issue:
#include <signal.h>
int main(void)
int si_value = 0;
return 0;
If I try to compile this with the GNU C Compiler gcc
, I get the following error:
> gcc example.c
In file included from /usr/include/signal.h:57:0,
from example.c:2:
example.c: In function âÂÂmainâÂÂ:
example.c:6:9: error: expected âÂÂ=âÂÂ, âÂÂ,âÂÂ, âÂÂ;âÂÂ, âÂÂasmâ or âÂÂ__attribute__â before âÂÂ.â token
int si_value = 0;
^
example.c:6:9: error: expected expression before âÂÂ.â token
Nonetheless, if I use another name such as si_value2
, the error doesn't show up. As a reference, I'm using GCC v7.3.0 on Ubuntu Mate 18.04.1 LTS. The same problem is observed with g++
.
I suppose that this behaviour is due to some macro definition inside the <signal.h>
header, but after going through it briefly, I couldn't seem to find anything really related.
I honestly can fix it by just using another name. However, my concern is: how could I elegantly avoid this type of issue in the future?
Update: As @F.X. has suggested, using gcc -E example.c
shows that the variable name is expanded (hence, the error):
...
int
# 6 "example.c" 3 4
_sifields._rt.si_sigval
# 6 "example.c"
= 0;
...
c++ c linux
c++ c linux
edited 27 mins ago
Boann
36.2k1286118
36.2k1286118
asked 2 hours ago
SRG
11210
11210
4
Can you look at the output ofgcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.
â F.X.
2 hours ago
4
Is it just the namesi_value
? Smells like a macro is getting substituted into your code. What about something likesi_vy1ghad563nvy43wd
?
â alter igel
2 hours ago
2
@alterigel sorry,si_vy1ghad563nvy43wd
is also a reserved keyword.
â Jean-François Fabre
2 hours ago
2
@Jean-FrançoisFabre sorry,si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see howsi_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.
â Andrew Henle
2 hours ago
3
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago
 |Â
show 7 more comments
4
Can you look at the output ofgcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.
â F.X.
2 hours ago
4
Is it just the namesi_value
? Smells like a macro is getting substituted into your code. What about something likesi_vy1ghad563nvy43wd
?
â alter igel
2 hours ago
2
@alterigel sorry,si_vy1ghad563nvy43wd
is also a reserved keyword.
â Jean-François Fabre
2 hours ago
2
@Jean-FrançoisFabre sorry,si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see howsi_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.
â Andrew Henle
2 hours ago
3
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago
4
4
Can you look at the output of
gcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.â F.X.
2 hours ago
Can you look at the output of
gcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.â F.X.
2 hours ago
4
4
Is it just the name
si_value
? Smells like a macro is getting substituted into your code. What about something like si_vy1ghad563nvy43wd
?â alter igel
2 hours ago
Is it just the name
si_value
? Smells like a macro is getting substituted into your code. What about something like si_vy1ghad563nvy43wd
?â alter igel
2 hours ago
2
2
@alterigel sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword.â Jean-François Fabre
2 hours ago
@alterigel sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword.â Jean-François Fabre
2 hours ago
2
2
@Jean-FrançoisFabre sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see how si_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.â Andrew Henle
2 hours ago
@Jean-FrançoisFabre sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see how si_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.â Andrew Henle
2 hours ago
3
3
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago
 |Â
show 7 more comments
2 Answers
2
active
oldest
votes
up vote
11
down vote
accepted
<signal.h>
doesn't actually prevent using si_
as a prefix on your variables. However, the POSIX specification states that this prefix is reserved, in order to allow the header and the library functions that it declares to use these names, without having to worry that they'll conflict with your own variables.
So what's happening here is that si_value
is defined in some way in the header file, perhaps as a macro or typedef, and your attempt to use the same name conflicts with this. If you used si_vy1ghad563nvy43wd
it probably would work, but theoretically the header could use that name (thinking that it would be unlikely to conflict with anything an application programmer would use).
C doesn't have real namespaces, so naming conventions like this are used as a simple substitute.
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
I think this is actually a POSIX thing, while__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.
â Barmar
1 hour ago
1
But isn'tsignal.h
a standard header?
â Kevin
1 hour ago
1
C11 reserves names startingSIG
followed by a capital letter, orSIG_
followed by a capital letter (C11 §7.14 Signal handling<signal.h>
). POSIX reserves a lot more symbol prefixes when<signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading__
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.
â Jonathan Leffler
1 hour ago
1
@Kevin: The<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify-std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified-std=c11
, you might need to write-D_XOPEN_SOURCE=700
on the compiler command line, or a similar#define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).
â Jonathan Leffler
1 hour ago
 |Â
show 4 more comments
up vote
7
down vote
how could I elegantly avoid this type of issues in the future?
You check some documentation for the headers you are using and avoid the names that are documented as reserved.
1
Where does it say thatsi_value
is a reserved name? All I see is references to a field of that name in thesiginfo_t
structure, but that's not at all the same thing?
â unwind
2 hours ago
@unwind, the prefixsi_
is reserved when using<signal.h>
â R Sahu
2 hours ago
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a_t
suffix
â VTT
2 hours ago
 |Â
show 5 more comments
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
<signal.h>
doesn't actually prevent using si_
as a prefix on your variables. However, the POSIX specification states that this prefix is reserved, in order to allow the header and the library functions that it declares to use these names, without having to worry that they'll conflict with your own variables.
So what's happening here is that si_value
is defined in some way in the header file, perhaps as a macro or typedef, and your attempt to use the same name conflicts with this. If you used si_vy1ghad563nvy43wd
it probably would work, but theoretically the header could use that name (thinking that it would be unlikely to conflict with anything an application programmer would use).
C doesn't have real namespaces, so naming conventions like this are used as a simple substitute.
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
I think this is actually a POSIX thing, while__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.
â Barmar
1 hour ago
1
But isn'tsignal.h
a standard header?
â Kevin
1 hour ago
1
C11 reserves names startingSIG
followed by a capital letter, orSIG_
followed by a capital letter (C11 §7.14 Signal handling<signal.h>
). POSIX reserves a lot more symbol prefixes when<signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading__
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.
â Jonathan Leffler
1 hour ago
1
@Kevin: The<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify-std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified-std=c11
, you might need to write-D_XOPEN_SOURCE=700
on the compiler command line, or a similar#define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).
â Jonathan Leffler
1 hour ago
 |Â
show 4 more comments
up vote
11
down vote
accepted
<signal.h>
doesn't actually prevent using si_
as a prefix on your variables. However, the POSIX specification states that this prefix is reserved, in order to allow the header and the library functions that it declares to use these names, without having to worry that they'll conflict with your own variables.
So what's happening here is that si_value
is defined in some way in the header file, perhaps as a macro or typedef, and your attempt to use the same name conflicts with this. If you used si_vy1ghad563nvy43wd
it probably would work, but theoretically the header could use that name (thinking that it would be unlikely to conflict with anything an application programmer would use).
C doesn't have real namespaces, so naming conventions like this are used as a simple substitute.
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
I think this is actually a POSIX thing, while__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.
â Barmar
1 hour ago
1
But isn'tsignal.h
a standard header?
â Kevin
1 hour ago
1
C11 reserves names startingSIG
followed by a capital letter, orSIG_
followed by a capital letter (C11 §7.14 Signal handling<signal.h>
). POSIX reserves a lot more symbol prefixes when<signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading__
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.
â Jonathan Leffler
1 hour ago
1
@Kevin: The<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify-std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified-std=c11
, you might need to write-D_XOPEN_SOURCE=700
on the compiler command line, or a similar#define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).
â Jonathan Leffler
1 hour ago
 |Â
show 4 more comments
up vote
11
down vote
accepted
up vote
11
down vote
accepted
<signal.h>
doesn't actually prevent using si_
as a prefix on your variables. However, the POSIX specification states that this prefix is reserved, in order to allow the header and the library functions that it declares to use these names, without having to worry that they'll conflict with your own variables.
So what's happening here is that si_value
is defined in some way in the header file, perhaps as a macro or typedef, and your attempt to use the same name conflicts with this. If you used si_vy1ghad563nvy43wd
it probably would work, but theoretically the header could use that name (thinking that it would be unlikely to conflict with anything an application programmer would use).
C doesn't have real namespaces, so naming conventions like this are used as a simple substitute.
<signal.h>
doesn't actually prevent using si_
as a prefix on your variables. However, the POSIX specification states that this prefix is reserved, in order to allow the header and the library functions that it declares to use these names, without having to worry that they'll conflict with your own variables.
So what's happening here is that si_value
is defined in some way in the header file, perhaps as a macro or typedef, and your attempt to use the same name conflicts with this. If you used si_vy1ghad563nvy43wd
it probably would work, but theoretically the header could use that name (thinking that it would be unlikely to conflict with anything an application programmer would use).
C doesn't have real namespaces, so naming conventions like this are used as a simple substitute.
edited 1 hour ago
Jonathan Leffler
552k866561009
552k866561009
answered 2 hours ago
Barmar
410k34235337
410k34235337
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
I think this is actually a POSIX thing, while__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.
â Barmar
1 hour ago
1
But isn'tsignal.h
a standard header?
â Kevin
1 hour ago
1
C11 reserves names startingSIG
followed by a capital letter, orSIG_
followed by a capital letter (C11 §7.14 Signal handling<signal.h>
). POSIX reserves a lot more symbol prefixes when<signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading__
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.
â Jonathan Leffler
1 hour ago
1
@Kevin: The<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify-std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified-std=c11
, you might need to write-D_XOPEN_SOURCE=700
on the compiler command line, or a similar#define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).
â Jonathan Leffler
1 hour ago
 |Â
show 4 more comments
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
I think this is actually a POSIX thing, while__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.
â Barmar
1 hour ago
1
But isn'tsignal.h
a standard header?
â Kevin
1 hour ago
1
C11 reserves names startingSIG
followed by a capital letter, orSIG_
followed by a capital letter (C11 §7.14 Signal handling<signal.h>
). POSIX reserves a lot more symbol prefixes when<signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading__
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.
â Jonathan Leffler
1 hour ago
1
@Kevin: The<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify-std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified-std=c11
, you might need to write-D_XOPEN_SOURCE=700
on the compiler command line, or a similar#define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).
â Jonathan Leffler
1 hour ago
1
1
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
Aren't identifiers starting with '__' reserved for the implementation? Can't it use that instead? Or is that something else?
â Kevin
1 hour ago
2
2
I think this is actually a POSIX thing, while
__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.â Barmar
1 hour ago
I think this is actually a POSIX thing, while
__
is a C thing. So POSIX is trying to avoid names that are reserved to the C implementation.â Barmar
1 hour ago
1
1
But isn't
signal.h
a standard header?â Kevin
1 hour ago
But isn't
signal.h
a standard header?â Kevin
1 hour ago
1
1
C11 reserves names starting
SIG
followed by a capital letter, or SIG_
followed by a capital letter (C11 §7.14 Signal handling <signal.h>
). POSIX reserves a lot more symbol prefixes when <signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading __
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.â Jonathan Leffler
1 hour ago
C11 reserves names starting
SIG
followed by a capital letter, or SIG_
followed by a capital letter (C11 §7.14 Signal handling <signal.h>
). POSIX reserves a lot more symbol prefixes when <signal.h>
is included â §2.2.2 The Name Space. The C standard reserves leading __
for use by the implementation (C11 §7.1.3 Reserved identifiers). Read and take care to avoid conflicts. Or fix 'em when they arise.â Jonathan Leffler
1 hour ago
1
1
@Kevin: The
<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify -std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified -std=c11
, you might need to write -D_XOPEN_SOURCE=700
on the compiler command line, or a similar #define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).â Jonathan Leffler
1 hour ago
@Kevin: The
<signal.h>
header is both a standard C header and a standard POSIX header. Since you didn't specify -std=c11
or similar when you invoked GCC, it enabled all the GNU extensions, which includes the POSIX functions and symbols. If you specified -std=c11
, you might need to write -D_XOPEN_SOURCE=700
on the compiler command line, or a similar #define
in a header or your code (I recommend doing it in a header, having used it in code once upon a decade ago, and having spent a fair amount of time undoing it since then).â Jonathan Leffler
1 hour ago
 |Â
show 4 more comments
up vote
7
down vote
how could I elegantly avoid this type of issues in the future?
You check some documentation for the headers you are using and avoid the names that are documented as reserved.
1
Where does it say thatsi_value
is a reserved name? All I see is references to a field of that name in thesiginfo_t
structure, but that's not at all the same thing?
â unwind
2 hours ago
@unwind, the prefixsi_
is reserved when using<signal.h>
â R Sahu
2 hours ago
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a_t
suffix
â VTT
2 hours ago
 |Â
show 5 more comments
up vote
7
down vote
how could I elegantly avoid this type of issues in the future?
You check some documentation for the headers you are using and avoid the names that are documented as reserved.
1
Where does it say thatsi_value
is a reserved name? All I see is references to a field of that name in thesiginfo_t
structure, but that's not at all the same thing?
â unwind
2 hours ago
@unwind, the prefixsi_
is reserved when using<signal.h>
â R Sahu
2 hours ago
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a_t
suffix
â VTT
2 hours ago
 |Â
show 5 more comments
up vote
7
down vote
up vote
7
down vote
how could I elegantly avoid this type of issues in the future?
You check some documentation for the headers you are using and avoid the names that are documented as reserved.
how could I elegantly avoid this type of issues in the future?
You check some documentation for the headers you are using and avoid the names that are documented as reserved.
answered 2 hours ago
Baum mit Augen
39.8k12112145
39.8k12112145
1
Where does it say thatsi_value
is a reserved name? All I see is references to a field of that name in thesiginfo_t
structure, but that's not at all the same thing?
â unwind
2 hours ago
@unwind, the prefixsi_
is reserved when using<signal.h>
â R Sahu
2 hours ago
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a_t
suffix
â VTT
2 hours ago
 |Â
show 5 more comments
1
Where does it say thatsi_value
is a reserved name? All I see is references to a field of that name in thesiginfo_t
structure, but that's not at all the same thing?
â unwind
2 hours ago
@unwind, the prefixsi_
is reserved when using<signal.h>
â R Sahu
2 hours ago
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a_t
suffix
â VTT
2 hours ago
1
1
Where does it say that
si_value
is a reserved name? All I see is references to a field of that name in the siginfo_t
structure, but that's not at all the same thing?â unwind
2 hours ago
Where does it say that
si_value
is a reserved name? All I see is references to a field of that name in the siginfo_t
structure, but that's not at all the same thing?â unwind
2 hours ago
@unwind, the prefix
si_
is reserved when using <signal.h>
â R Sahu
2 hours ago
@unwind, the prefix
si_
is reserved when using <signal.h>
â R Sahu
2 hours ago
1
1
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
@unwind 2.2.2 The namespace
â user463035818
2 hours ago
1
1
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
how can a prefix be reserved?
â Jean-François Fabre
2 hours ago
3
3
@Jean-FrançoisFabre Probably in the same manner they've reserved a
_t
suffixâ VTT
2 hours ago
@Jean-FrançoisFabre Probably in the same manner they've reserved a
_t
suffixâ VTT
2 hours ago
 |Â
show 5 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53196962%2fwhy-does-signal-h-prevent-the-use-of-si-as-prefix-for-the-name-of-some-vari%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
Can you look at the output of
gcc -E
(right after preprocessor)? It might give you a hint as to what goes wrong.â F.X.
2 hours ago
4
Is it just the name
si_value
? Smells like a macro is getting substituted into your code. What about something likesi_vy1ghad563nvy43wd
?â alter igel
2 hours ago
2
@alterigel sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword.â Jean-François Fabre
2 hours ago
2
@Jean-FrançoisFabre sorry,
si_vy1ghad563nvy43wd
is also a reserved keyword Where is that a reserved keyword? If it exists, I can't find that in POSIX nor the C standard. Offhand, I don't even see howsi_value
fits into the POSIX "functions and external identifiers" reservation of identifiers.â Andrew Henle
2 hours ago
3
@AndrewHenle okay this was a joke.
â Jean-François Fabre
2 hours ago