c++ Include in linux, and gcc raises error which occurs within ? [closed]
I try to use bitset in my c++ code, the desired behavior is my code man pass compiling and use bitset correctly.
The specific problem is while compiling gcc raise this:
g++ -g -Wall -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine -DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/synch.cc
In file included from ../machine/machine.h:28:0,
from ../threads/thread.h:47,
from ../threads/synch.h:21,
from ../threads/synch.cc:26:
/usr/include/c++/4.6/bitset: In member function 'void std::bitset<_Nb>::_M_copy_from_ptr(const _CharT*, std::size_t, std::size_t, std::size_t, _CharT, _CharT)':
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
what does " expected unqualified-id before '(' token" mean, and how do I fix this?
1371 line of file bitset is :
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __s[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_Unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
}
}
c++ std bitset
closed as off-topic by Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight Nov 22 '18 at 9:23
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight
If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 1 more comment
I try to use bitset in my c++ code, the desired behavior is my code man pass compiling and use bitset correctly.
The specific problem is while compiling gcc raise this:
g++ -g -Wall -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine -DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/synch.cc
In file included from ../machine/machine.h:28:0,
from ../threads/thread.h:47,
from ../threads/synch.h:21,
from ../threads/synch.cc:26:
/usr/include/c++/4.6/bitset: In member function 'void std::bitset<_Nb>::_M_copy_from_ptr(const _CharT*, std::size_t, std::size_t, std::size_t, _CharT, _CharT)':
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
what does " expected unqualified-id before '(' token" mean, and how do I fix this?
1371 line of file bitset is :
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __s[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_Unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
}
}
c++ std bitset
closed as off-topic by Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight Nov 22 '18 at 9:23
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight
If this question can be reworded to fit the rules in the help center, please edit the question.
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42
|
show 1 more comment
I try to use bitset in my c++ code, the desired behavior is my code man pass compiling and use bitset correctly.
The specific problem is while compiling gcc raise this:
g++ -g -Wall -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine -DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/synch.cc
In file included from ../machine/machine.h:28:0,
from ../threads/thread.h:47,
from ../threads/synch.h:21,
from ../threads/synch.cc:26:
/usr/include/c++/4.6/bitset: In member function 'void std::bitset<_Nb>::_M_copy_from_ptr(const _CharT*, std::size_t, std::size_t, std::size_t, _CharT, _CharT)':
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
what does " expected unqualified-id before '(' token" mean, and how do I fix this?
1371 line of file bitset is :
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __s[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_Unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
}
}
c++ std bitset
I try to use bitset in my c++ code, the desired behavior is my code man pass compiling and use bitset correctly.
The specific problem is while compiling gcc raise this:
g++ -g -Wall -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine -DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/synch.cc
In file included from ../machine/machine.h:28:0,
from ../threads/thread.h:47,
from ../threads/synch.h:21,
from ../threads/synch.cc:26:
/usr/include/c++/4.6/bitset: In member function 'void std::bitset<_Nb>::_M_copy_from_ptr(const _CharT*, std::size_t, std::size_t, std::size_t, _CharT, _CharT)':
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
/usr/include/c++/4.6/bitset:1371:30: error: expected unqualified-id before '(' token
what does " expected unqualified-id before '(' token" mean, and how do I fix this?
1371 line of file bitset is :
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
size_t __pos, size_t __n, _CharT __zero, _CharT __one)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos));
for (size_t __i = __nbits; __i > 0; --__i)
{
const _CharT __c = __s[__pos + __nbits - __i];
if (_Traits::eq(__c, __zero))
;
else if (_Traits::eq(__c, __one))
_Unchecked_set(__i - 1);
else
__throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
}
}
c++ std bitset
c++ std bitset
edited Nov 23 '18 at 7:59
pkutp
asked Nov 22 '18 at 6:39
pkutppkutp
62
62
closed as off-topic by Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight Nov 22 '18 at 9:23
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight Nov 22 '18 at 9:23
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Some programmer dude, πάντα ῥεῖ, Killzone Kid, gsamaras, Toby Speight
If this question can be reworded to fit the rules in the help center, please edit the question.
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42
|
show 1 more comment
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42
|
show 1 more comment
1 Answer
1
active
oldest
votes
Hard to say from just this snippet, but pretty much the only reason syntax errors happen in system headers is that your code defines a macro that somehow conflicts with the code.
The most likely candidate here is min
. A macro by this name is unfortunately quite wide-spread; e.g. windows.h
defines one unless you define NOMINMAX
before including it. There are other headers that do the same thing.
One thing you can do to diagnose this is to put this code snippet after every individual include in your source files:
#if defined(min)
#error Previous include defined min
#endif
Then once you know which header is responsible, you can try to find out how to prevent it from doing that (or #undef the macro if necessary).
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hard to say from just this snippet, but pretty much the only reason syntax errors happen in system headers is that your code defines a macro that somehow conflicts with the code.
The most likely candidate here is min
. A macro by this name is unfortunately quite wide-spread; e.g. windows.h
defines one unless you define NOMINMAX
before including it. There are other headers that do the same thing.
One thing you can do to diagnose this is to put this code snippet after every individual include in your source files:
#if defined(min)
#error Previous include defined min
#endif
Then once you know which header is responsible, you can try to find out how to prevent it from doing that (or #undef the macro if necessary).
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
add a comment |
Hard to say from just this snippet, but pretty much the only reason syntax errors happen in system headers is that your code defines a macro that somehow conflicts with the code.
The most likely candidate here is min
. A macro by this name is unfortunately quite wide-spread; e.g. windows.h
defines one unless you define NOMINMAX
before including it. There are other headers that do the same thing.
One thing you can do to diagnose this is to put this code snippet after every individual include in your source files:
#if defined(min)
#error Previous include defined min
#endif
Then once you know which header is responsible, you can try to find out how to prevent it from doing that (or #undef the macro if necessary).
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
add a comment |
Hard to say from just this snippet, but pretty much the only reason syntax errors happen in system headers is that your code defines a macro that somehow conflicts with the code.
The most likely candidate here is min
. A macro by this name is unfortunately quite wide-spread; e.g. windows.h
defines one unless you define NOMINMAX
before including it. There are other headers that do the same thing.
One thing you can do to diagnose this is to put this code snippet after every individual include in your source files:
#if defined(min)
#error Previous include defined min
#endif
Then once you know which header is responsible, you can try to find out how to prevent it from doing that (or #undef the macro if necessary).
Hard to say from just this snippet, but pretty much the only reason syntax errors happen in system headers is that your code defines a macro that somehow conflicts with the code.
The most likely candidate here is min
. A macro by this name is unfortunately quite wide-spread; e.g. windows.h
defines one unless you define NOMINMAX
before including it. There are other headers that do the same thing.
One thing you can do to diagnose this is to put this code snippet after every individual include in your source files:
#if defined(min)
#error Previous include defined min
#endif
Then once you know which header is responsible, you can try to find out how to prevent it from doing that (or #undef the macro if necessary).
answered Nov 22 '18 at 9:01
Sebastian RedlSebastian Redl
50.5k476116
50.5k476116
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
add a comment |
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
Thank you. I did define min elsewhere. After removing it the problem is solved.
– pkutp
Nov 23 '18 at 8:05
add a comment |
Please don't post image of text, copy-paste it as text, in full and complete, into the question instead. And we don't need to see the system header, because the cause of the error isn't there, it's in your code. So also please shown us an Minimal, Complete, and Verifiable example of your code causing the error. Also please read about how to ask good questions, as well as this question checklist.
– Some programmer dude
Nov 22 '18 at 6:42
The message is 1371, not 1731
– M.M
Nov 22 '18 at 6:46
Thank you. I will paste words.
– pkutp
Nov 22 '18 at 8:38
But gcc compiler says the error is in the system header. This is where I don't understand and want to ask.
– pkutp
Nov 22 '18 at 8:40
Thank you, it is 1371, "1731" is just a typo and the code i paste is actually 1371.
– pkutp
Nov 22 '18 at 8:42