Take the 2-minute tour ×

I had some decryption code (using wincrypt.h) that lived within my FileReader.cpp class. I am trying to segregate the code and push this decryption method into a MyCrypt.cpp class. However, upon moving it I'm stuck with a bunch of errors that I wasn't facing before. For every wincrypt.h or windows.h specific command, I am recieving "identifier not found" or "undeclared identifier".

What gives!

More details..

Sample errors:

error C2065: 'HCRYPTPROV' : undeclared identifier

error C3861: 'CryptDecrypt': identifier not found

I am including windows.h and wincrypt.h, just as I was in FileReader.cpp.

#include "MyCrypt.h"
#include <windows.h>
#include <wincrypt.h>

MyCrypt.h is defined as:

#pragma once

class MyCrypt
    static char *DecryptMyFile(char *input, char *password, int size, int originalSize) ;

    static const DWORD KEY_LENGTH = 128;

If I rearrange my include files, I get the following errors instead:

error C2628: 'MyCrypt' followed by 'char' is illegal (did you forget a ';'?) error C2556: 'MyCrypt *MyCrypt::DecryptMyFile(char *,char *,int,int)' : overloaded function differs only by return type from 'char *MyCrypt::DecryptMyFile(char *,char *,int,int)

But nowhere in my code does it use this redefinition it speaks of..

share|improve this question
#include problem ? –  JRL Oct 28 '09 at 15:56
can you post more details? Like, say, the line it errors out on and the full error you get? –  Herms Oct 28 '09 at 15:56
Does MyCrypt.cpp #include wincrypt.h and windows.h in the same way that FileReader.cpp was? –  Éric Malenfant Oct 28 '09 at 15:58
provide the code and errors –  Tim Oct 28 '09 at 16:00
Added more details to description –  Mark Oct 28 '09 at 16:05
add comment

5 Answers

up vote 2 down vote accepted

Check MyCrypt.h and make sure there's a ; after the closing brace. I've seen some fairly strange error messages when I've missed that. It's missing in the sample you posted.

share|improve this answer
...Quite unfortunate. –  Mark Oct 28 '09 at 16:45
That's bitten me a few times too, especially when I go back to C++ after using other languages for a while. It's one of the first things I check now. :) –  Herms Oct 28 '09 at 20:48
add comment

Did you forget the semicolon after your class declaration?

share|improve this answer
add comment

Sounds like the code you moved out of FileReader.cpp was either referencing member variables of that class which don't exist in MyCrypt.cpp or methods that were #included in FileReader.cpp that weren't included in MyCrypt.cpp.

share|improve this answer
This was my initial impression but it doesn't seem to be the case. I have updated my description with a few more details. –  Mark Oct 28 '09 at 16:03
add comment

Sounds like you are now missing some #include's in the new MyCrypt.cpp file, such as windows.h and wincrypt.h, but we need the actual errors to specifically helpful.

share|improve this answer
I thought this as well, but I don't believe so while double checking. I have added more details to my description –  Mark Oct 28 '09 at 16:03
add comment

Some ideas:

  • are you calling methods without referencing the object first (since they were in the old class and now moved, maybe you forgot to call them through a pointer in the new class?)
  • you could try shifting the order of the include statements.
  • are you using precompiled headers? You could try without to see if that fixes the problem.
share|improve this answer
Going through and trying these...Removing my precompiled header reference yields a compiler error. "unexpected end of file while looking for precompiled header" –  Mark Oct 28 '09 at 16:20
Added the results of rearranging my include statements to the description –  Mark Oct 28 '09 at 16:29
add comment

Your Answer


