Jump to content

Runtime error for sc_module_name on msvc

Navaneet kumar

Recommended Posts


I have written a very simple sc_module and created a dll library (libmodule.dll and .lib) for the same under cygwin using msvc cmdline (corresponding to visual studio 2015). I then link this module with a sc_main program, which calls module constructor. As soon as the program is executed, I get this error:

Error: (E533) module name stack is empty: did you forget to add a sc_module_name parameter to your module constructor?
In file: ..\..\src\sysc\kernel\sc_object_manager.cpp:373

What could be the issue?

Here is example source code:

// Module.h

class DLL_API myclass : public sc_core::sc_module
        myclass(sc_core::sc_module_name name) ;
        void display();


// Module.cpp

myclass::myclass(sc_core::sc_module_name name) : sc_core::sc_module(name) 
        std::cout << "Inside cons\n";
void myclass::display()
        std::cout << "Calling display\n";

// DLL_API is defined as

#define DLL_API   __declspec(dllexport)
#define DLL_API   __declspec(dllimport)

// Main program

int sc_main(int argc, char * argv[])
   myclass obj("myclass");

   return 0;

//Compilation cmds

cl /MD /EHsc /D DLL_EXPORT /I "C:\external_dep\systemc-2.3.1\src" -c Module.cpp
link /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NOLOGO /DLL /OPT:REF /OPT:ICF /DYNAMICBASE:NO /NXCOMPAT /MACHINE:"X64" /LIBPATH:"C:\external_dep\systemc-2.3.1\msvc80\SystemC\x64\Release"  /OUT:"libmodule.dll" SystemC.lib Module.obj
cl /MD /EHsc /D DLL_EXPORT /I "C:\external_dep\systemc-2.3.1\src" -c sc_main.cpp
link /SUBSYSTEM:CONSOLE /LIBPATH:"C:\external_dep\systemc-2.3.1\msvc80\SystemC\x64\Release" SystemC.lib libmodule.lib sc_main.obj
./sc_main.exe <- running this gives above error


Surprisingly, when I move Module constructor body from Module.cpp to Module.h, the error goes away.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...