Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,158 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,107 people online right now. Registration is fast and FREE... Join Now!




DWORD problem

 
Reply to this topicStart new topic

DWORD problem, DWORD throws an error C2146

zakary
6 Dec, 2007 - 07:05 AM
Post #1

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 404



Thanked: 6 times
Dream Kudos: 175
My Contributions
I am a C# developer. I am wrapping an unmanaged C++ dll. when I compile my C++ managed wrapper class and header files. I get an error C2146: syntax error ';' missing before identifier 'getLength' my line of code is:

public:
MessageType getType() const { return MessageType(m_type); }
DWORD getLength() const { return m_length; }

not sure why it would do this I right click on DWORD and it opens the windows windef.h file. so it is declared.

Thanks for any help you can provide.
User is offlineProfile CardPM
+Quote Post

skaoth
RE: DWORD Problem
6 Dec, 2007 - 07:31 AM
Post #2

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
I think more context is needed.
Can you provide the block of code that is flagging the error?

User is online!Profile CardPM
+Quote Post

zakary
RE: DWORD Problem
6 Dec, 2007 - 07:37 AM
Post #3

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 404



Thanked: 6 times
Dream Kudos: 175
My Contributions
here is the block of code I am still searching the MSDN to see if there is anything there. THANKS

CODE
struct Message
{
public:
    MessageType    getType() const { return MessageType(m_type); }
    DWORD        getLength() const { return m_length; }

protected:
    Message(MessageType type, DWORD length) : m_type (type), m_length(length) { }

    void        set_length(DWORD length) { m_length = length; }

private:
    DWORD    m_type;
    DWORD    m_length;
};


Mod edit: added code tags: code.gif
User is offlineProfile CardPM
+Quote Post

skaoth
RE: DWORD Problem
6 Dec, 2007 - 08:33 AM
Post #4

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
I'm sorry, but can you also post the MessageType type.
Is this also a DWORD?

The constructor leads me to believe this but just wanted to
double check
User is online!Profile CardPM
+Quote Post

zakary
RE: DWORD Problem
6 Dec, 2007 - 08:43 AM
Post #5

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 404



Thanked: 6 times
Dream Kudos: 175
My Contributions
sorry

CODE
enum MessageType
{
    Response,
    Start,
    StartFrom,
    StartFromTo,
    StartFrequencies,
    StartFromFrequencies,
    StartFromToFrequencies,
    Stop,
    Pause,
    Resume,
    JumpTo,
    StartTime,
    GetStartTime,
    EndTime,
    GetEndTime,
    CurrentTime,
    GetCurrentTime,
    NumberOfFrequencies,
    GetNumberOfFrequencies,
    FrequencyList,
    GetFrequencyList,
    NumberOfRadios,
    GetNumberOfRadios,
    RadioList,            // not implemented yet
    GetRadioList,
    SkipSilence,
    WriteToWave,
    WriteToAVI,
    GetWriteCurrentTime,
    WriteCurrentTime,
    GetDISPlaybackInfo,
    DISPlaybackInfo,
    GetDISRecordInfo,
    DISRecordInfo,
    GetWriteStatus,
    WriteStatus,
    Dummy
};


DWORD is part of the windef.h windows file. the error is at compilation and it is expecting the ; after the DWORD, but if i use unsigned long and not DWORD it will compile I think my VS2005 is corrupt I may have to reinstall it.

Mod Edit: added code tags: code.gif
User is offlineProfile CardPM
+Quote Post

skaoth
RE: DWORD Problem
6 Dec, 2007 - 09:29 AM
Post #6

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
Are you including <windef>?

Try using#include <windows.h>
User is online!Profile CardPM
+Quote Post

zakary
RE: DWORD Problem
6 Dec, 2007 - 10:57 AM
Post #7

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 404



Thanked: 6 times
Dream Kudos: 175
My Contributions
Thanks Skaoth What a stupid thing to do I assumed it could see, but the include fixed Thanks again.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 11:34PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month