CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Jul 2010
    Posts
    18

    #define to static const int

    I have my ideas of scope messed up.

    I have a native DLL which I am compiling with /CLR in hopes to export Native global functions and constants. To do so I have created a class I am hoping I can call from C# or VB.Net clients statically.. so:
    Code:
    namespace CompanyNameManaged {
    
    public ref struct CompanyName sealed abstract
    {
        
    static void func1(String^ filename, int page); //called from c# like CompanyName.func1("literal", 9);
    
    // These are #defined in a seperate, unmanaged file
    ref struct CONSTANTS sealed abstract
    {
            
    //From Native Header: #define DEF01 0x0001
    const int DEF01 = 0x0001; //doesnt compile, needs to be "Static"
    static const int DEF02 = 0x0002; //works, called from DLL as CompanyName.CONSTANTS.DEF02;
    static const int DEF03 = 0x0003; 
    //DEF03 is defined in windows api file "WinGdi.h" I dont believe I am including this file anywhere 
    //but I believe this is the source of my problem since when I change name (MY_DEF03) it compiles.
    
    }; //ref stuct CONSTANTS
    
    }; //ref struct CompanyName
    
    }; //namespace
    SO, when I try to compile with the const "DEF03" I have issues, the error is:
    error C2059: syntax error : 'constant'
    error C2238: unexpected token(s) preceding ';'

    It shouldnt have an issue because I think the scope is "CompanyName::CONSTANTS:EF03"

    Should I be declaring the wrapper classes differently? The purpose here is to expose native code to the client.

    Thanks in advanced.
    Last edited by TFobear; August 3rd, 2010 at 09:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured