0

I would like to know what is the exact difference between those two terms. some search results say that # is the signal for preprocessor and next to that symbol would be the directive. As example

"#" :- preprocessor symbol

"include" :- directive

So #include call as preprocessor directive itself. If so, please tell me examples for the preprocessor directive vs directive in C++ ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
77bizmarck
  • 9
  • 1
  • 3
  • 10
    There are no non-preprocessor directives. It is not clear why you assume they exist. – n. m. could be an AI Nov 29 '16 at 08:32
  • @n.m ok I will update that non preprocessor word towards to my original question then thanks. – 77bizmarck Nov 29 '16 at 09:37
  • 2
    @77bizmarck When you ask "preprocessor directive" vs "directive" you essentially ask if there is some directive that is not a preprocessor directive. It doesn't matter if you call it "non-preprocesor directive" or not. There is no such thing. `#` symbol followed by a command like `include` is one entity. They don't exist separately. – freakish Nov 29 '16 at 09:42
  • Instead of "some search results", learn the language from [a proper book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) whose author knows what they're talking about. – Lightness Races in Orbit Mar 11 '18 at 12:36

1 Answers1

3

#include is the start of a preprocessor directive. It consists of a # character followed by the directive's name. There are then additional pieces of information that come after it. An example of a full preprocessor directive might be:

#include <string>

It directs the preprocessor to do something (in this case, to include the string header).

The term "directive" may also be found in other contexts in C++. For example, the following is a using-directive:

using namespace std;

I would advise not getting hung up on the word "directive". It's just an English term for "a command to do a thing".

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055