0

I am using GCC 7.5. When building packages, it complains about ordered comparison between integer and pointer, so I change the 0 in the comparison to nullptr.

But then I receive an error message that "'nullptr' was not declared in this scope".

Trying adding options -std=c++11 or -std=c++14 does not help.

All the programs are in C++.

1

1 Answer 1

1

it complains about ordered comparison between integer and pointer

"Ordered comparison" means comparison with > or < or >= or <=. It makes no sense to compare a pointer with a null pointer constant this way.

so I change the 0 in the comparison to nullptr

This doesn't make the comparison any more meaningful. It makes no sense to compare a pointer with a null pointer constant this way either.

But then I receive an error message that "'nullptr' was not declared in this scope".

This cannot happen with gcc 7.5 unless you

  • compile C rather than C++ or
  • pass -std=c++98 or -std=c++03 somewhere or
  • have a broken installation of gcc.

In any case you probably want to fix the comparison (perhaps change > or < to !=) and only then think of maybe replacing 0 with nullptr.

Sign up to request clarification or add additional context in comments.

10 Comments

There are no std options in the command line according the build log. Can it be the program is in C? Even if the file has extension .cpp? Can it be fixed?
Should I also change <=0 to =0?
I have no idea who would write a condition like pointer <= 0 and why. This makes no sense whatsoever to me so I have no idea whether == 0 or != 0 or anything else would be a good replacement (probably not). Perhaps ask a separate question about it and provide enough context.
So, I fixed the issues by removing ordered comparisons... Everything builds now, but I do not know if it will work.
To what should I change this? if (mixer_handle >= 0)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.