tags:

views:

83

answers:

5

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
{
public:
    static char *DecryptMyFile(char *input, char *password, int size, int originalSize) ;

private:
    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..

+1  A: 

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.

Herms
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
A: 

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.

Clay Fowler
I thought this as well, but I don't believe so while double checking. I have added more details to my description
Mark
A: 

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.
JRL
Going through and trying these...Removing my precompiled header reference yields a compiler error. "unexpected end of file while looking for precompiled header"
Mark
Added the results of rearranging my include statements to the description
Mark
+1  A: 

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.

Herms
...Quite unfortunate.
Mark
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
+1  A: 

Did you forget the semicolon after your class declaration?

JRL