Reputation: 4571
I wrote
#ifndef Header1.h
#define Header1.h
class Complex
{
[...]
};
#endif
in my project (Visual Studio 2010) and I get an Error C2008: '.' : unexpected in macro definition. I don't understand what the problem is with "Header1.h" or how to fix it.
Upvotes: 0
Views: 5731
Reputation: 158449
You need to use an identifier here:
#ifndef Header1.h
^^^^^^^^^
and they can not include .
in them, we can see this from the draft C++ standard section 16
Preprocessing directives paragraph 1 which includes the following grammar:
# ifdef identifier new-line groupopt
^^^^^^^^^^
# ifndef identifier new-line groupopt
^^^^^^^^^^
typically include guards are all caps and an underscores:
#ifndef HEADER1_H
Upvotes: 2
Reputation: 3287
A macro name should not contain a dot. You'd better use
#ifndef HEADER1_H
#define HEADER1_H
...
#endif
Upvotes: 1
Reputation: 13973
Macro names can't contain periods. Rename it to Header1
or Header1h
.
As an aside, it's standard for most macros to be ALL_UPPERCASE.
Upvotes: 1
Reputation: 863
Don't use the . use an _ instead
#ifndef HEADER1_H
#define HEADER1_H
class Complex
{
[...]
};
#endif
Upvotes: 4