Nikolay Dakov
Nikolay Dakov

Reputation: 149

C++ Header file - syntax problems

I have some errors in my header file, which I don't know how to fix because I am fairly new to C++.

Here is the code of the header file:

#pragma once

typedef unsigned int uint;

class DCEncryption
{
public:
    static char* manageData(char*, char*, uint);

private:
    static int max(int, int);
    static uint leftRotate(uint, int);
};

And here are the errors:

 - dcencryption.h(12): error C2062: type 'int' unexpected
 - dcencryption.h(12): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
 - dcencryption.h(12): error C2760: syntax error : expected '{' not ';'
 - dcencryption.h(13): error C2144: syntax error : 'uint' should be preceded by '}'
 - dcencryption.h(13): error C2143: syntax error : missing ')' before ';'
 - dcencryption.h(13): error C2059: syntax error : ')'
 - dcencryption.h(13): error C2143: syntax error : missing ';' before ')'
 - dcencryption.h(13): error C2238: unexpected token(s) preceding ';'

Upvotes: 0

Views: 2155

Answers (1)

Jirka Hanika
Jirka Hanika

Reputation: 13529

You are probably on Windows and you have included windef.h directly or indirectly (through windows.h, maybe) from your main .cpp file before including the shown file.

It so happens that max is a macro defined in windef.h that does not expand nicely in your context.

This can quite easily happen on some other platforms as well.

Upvotes: 4

Related Questions