user1612986
user1612986

Reputation: 1415

c++ pragma #error giving an error

I recently came across a piece of code which uses the pragma directive

#error Error ! Define [_HOS_ | _HOS_OV_ | _HOV_].

This code is from the ADOC-C jacobian computation routine.

The problem is that in C++ visual studio 2010 there is a curly red line below the #error indicating there is some problem within that line.

The code also fails to compile giving error message at that line

Is there a syntax issue or are those [_HOS_ | _HOS_OV_ | _HOV_] not defined at that point, and intelliSense knows that resulting in curly red line indicating some problem?

Upvotes: 0

Views: 2328

Answers (3)

killdaclick
killdaclick

Reputation: 731

The problem is that in C++ visual studio 2010 there is a curly red line below the #error indicating there is some problem within that line.

Visual Studio 2010 does not recognize #error preprocesor syntax anymore. It only recognize #pragma warning

Upvotes: 0

Ivan Vergiliev
Ivan Vergiliev

Reputation: 3841

The intent of the #error directive is to create compile errors. It's usually a way for the programmer who wrote the code to tell the programmer that's trying to compile and use it "You did something wrong, this won't work!". The string following the directive is the message that should be shown to the programmer trying to compile the code.

You should check what directives are around this one, for example are there any #ifdefs that cause it to be executed. Then you should lookup the conditions in which they executed (e.g. not defining the things the error lists) and look for a way to make them go away.

Upvotes: 1

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

The author of that code intended to have an error when not at least one of the tags named in the error message is defined. You should have a look at the documentation of the ADOC-C stuff if s.th. is mentioned there about these tags.

Upvotes: 2

Related Questions