#error STOP issue ?

I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use
#error STOP

I have to comment out the inlcudes AFTER the first #error STOP for the compiler to do so.
If I uncomment the
#include <ff.h>
I get an error about missing ff.h which is correct since ff.h is not yet in project files.

This is no big deal, but
#error STOP should really stop compilation.

// code templates
// includes
// FATS stuff 
#include "diskio.h" // local copy 
//#error STOP 


//#include <ff.h>
//#include <ffconf.h>
//#include <integer.h>

#include "Arduino.h"
#include "utility.h" 

//#error STOP
//#include "CProcess.h" // link to application

If ff.h (and any other included files) is present and syntactically correct, what happens? I don't expect it would compile... I don't think it gets as far as looking at #errors if you try to #include files that don't exist.

DrAzzy:
If ff.h (and any other included files) is present and syntactically correct, what happens?

It compiles without problems.

I don't expect it would compile... I don't think it gets as far as looking at #errors if you try to #include files that don't exist.

The issue is it does not stop compilation when the file AFTER #error STOP does not exists.
Maybe I am not interpreting the #error STOP directive correctly, but it should cease compilation at #error STOP line , hence the following code should not be included in compilation , missing file should not be detected.

Maybe I should test this in "normal " code flow , not placing the #error STOP between #include(s).

Why do you care which error the compiler shows you when it can't compile the code?

Whether it's by a #error, or a missing include, the file won't be compiled....

DrAzzy:
Why do you care which error the compiler shows you when it can't compile the code?

Whether it's by a #error, or a missing include, the file won't be compiled....

Please read the OP.

"I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use
#error STOP"

Vaclav:
Please read the OP.

"I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use
#error STOP"

Compilation does terminate with error(s) when you use #error. It may not stop at the first error, but it's not required to (#error means "raise an error", not "stop compiling"). Show the compiler's output if you think it doesn't terminate.

Vaclav:
I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use
#error STOP

//#error STOP

You have commented-out the #error line so the compiler ignores it.

C++ tutorial

Better to remain silent and be thought a fool than to speak out and remove all doubt.

Abraham Lincoln

Don't administrators have to pass a reading test?

I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use
#error STOP

I have to comment out the inlcudes AFTER the first #error STOP for the compiler to do so.
If I uncomment the
#include <ff.h>
I get an error about missing ff.h which is correct since ff.h is not yet in project files.

This is no big deal, but
#error STOP should really stop compilation.

Don't administrators have to pass a reading test?

Vaclav - can you spell "moderator" ?
Does that look anything like "administrator"?

Albert Einstein — 'We all know that light travels faster than sound. That's why certain people appear bright until you hear them speak.'

Please post a short but complete program that exhibits the behavior you describe. The program you posted does not do what you say it does because (as Nick pointed out) the #error lines are commented out.

Here's what I think you're talking about:

#include <Arduino.h>
#error STOP
#include "no-such-file.h"

Compiler output:

sketch_jul08a.ino:2:2: error: #error STOP
sketch_jul08a.ino:3:26: error: no-such-file.h: No such file or directory

Looks fine to me.

If you expect the compilation to terminate at the #error line, your expectations are wrong. As I said already, an #error line means "raise an error". That's it. It will terminate the compilation at some point, not necessarily at that line.

Edit: I'm using Arduino 1.0.5-r2. Perhaps your version works differently. Please say what version you're using in case that's the case.

http://www.complete-concrete-concise.com/programming/c/preprocessor-–-the-error-directive

Horse's mouth

The directive `#error' causes the preprocessor to report a fatal error.

(my emphasis)

Vaclav:
I expect the compiler to terminate compilation when I use #error STOP
This is no big deal, but #error STOP should really stop compilation.
http://www.complete-concrete-concise.com/programming/c/preprocessor-–-the-error-directive

This is wrong, as it does not terminate anything. It will only prevent a successful build. What you want vs real world.

The compiler will always try and compile as far as it can. Which is why you'll see output until it can go no further from confusion with "fatal error".

And from the other horses mouth:

16.5 Error directive [cpp.error]
1 A preprocessing directive of the form

error pp-tokensopt new-line

causes the implementation to produce a diagnostic message that includes the specified sequence of preprocessing
tokens, and renders the program ill-formed.

Vaclav:
Don't administrators have to pass a reading test?

I am adding files to the project one at a time.

I expect the compiler to terminate compilation when I use

I know it is a bit much to ask, Vaclav, but I expect you to post code that demonstrates the problem.

Posting code and then saying "oh well if I change such-and-such I get a problem" isn't quite the same as posting the problem code itself.


Anyway, I'll bite. Your original code, excluding the comment lines, is this:

#include "diskio.h" // local copy
#include "Arduino.h"
#include "utility.h"

That generates two errors:

sketch_jul09a.ino:1:34: error: diskio.h: No such file or directory
sketch_jul09a.ino:3:21: error: utility.h: No such file or directory

Now you add the #error line:

#include "diskio.h" // local copy
#error STOP
#include "Arduino.h"
#include "utility.h

And you get three errors:

sketch_jul09a.ino:1:34: error: diskio.h: No such file or directory
sketch_jul09a.ino:2:2: error: #error STOP
sketch_jul09a.ino:4:21: error: utility.h: No such file or directory

Why are you so astonished at that? You already had two errors, now you have three.

Let's try more:

#include "diskio.h" // local copy
#error STOP
#error SLEDGING
#error ADMINISTRATORS
#include "Arduino.h"
#include "utility.h"

Gives us:

sketch_jul09a.ino:1:34: error: diskio.h: No such file or directory
sketch_jul09a.ino:2:2: error: #error STOP
sketch_jul09a.ino:3:2: error: #error SLEDGING
sketch_jul09a.ino:4:2: error: #error ADMINISTRATORS
sketch_jul09a.ino:6:21: error: utility.h: No such file or directory

Wow! Horror! Five errors!

I bet we could get up to 100 or so errors.

Better to remain silent and be thought a fool than to speak out and remove all doubt.

Ah yes, never a truer word was spoken.