Thread: Strange warning from MSVC 6

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Strange warning from MSVC 6

    d:\msvc 6 projects\dxenginedll\cdxaudio.h(87) : warning C4251: 'Sounds' : class 'std::vector<class CDXSoundSegment,class std::allocator<class CDXSoundSegment> >' needs to have dll-interface to be used by clients of class 'CDXSoundEmitter'
    What does this mean? CDXSoundEmitter is a class that wraps access to IDirectMusicSegment8 and IDirectMusicSegmentState8 interfaces.

    A sound emitter is the method I use to bypass separate audio paths. Each sound emitter controls the entire sound system. Ideally you would have one sound emitter for sound fx and one for digital music if need be. So a sound emitter contains a vector of CDXSoundSegments which represent the actual sounds and their associated data.

    What is MSVC trying to tell me here?
    I'm using this code to compile the DLL.

    DllCheck.h
    Code:
    #ifndef DllCheck_H
    #define DllCheck_H
    
    #ifdef _INSIDEDLL
    #define XTREME_DLL_DECL  __declspec(dllexport)
    #else
    #define XTREME_DLL_DECL __declspec(dllimport)
    #endif
    
    #endif
    Test.h
    Code:
    #ifndef Test_H
    #define Test_H
    
    #include "DllCheck.h"
    
    class XTREME_DLL_DECL Test
    {
    };
    
    #endif
    Then when I create the DLL and import library, I simply set the preprocessor options to define _INSIDEDLL and the XTREME_DLL_DECL becomes the export version. For the application using the class, it will not define this and therefore the XTREME_DLL_DECL becomes the import version.

    Then to use the import library you simply add it to the link section, include the right headers, and it works just like any other library.

    I'm switching the editor in MFC to use the actual engine view instead of a GDI one. It's easier and I don't have to mess around with GDI, DC's, etc, etc.

    The graphics engine will Initialize Direct3D in two ways. It can use either fullscreen or windowed mode and it also allows you to create a window for it. You simply set a boolean flag and it will use the HWND you supply it as the window handle and it won't create one for you. This allows me to specify any window I want which is quite nice for making editors. The InitD3D function also returns a pointer to a valid IDirect3DDevice9 so I can also draw inside of the window w/o using the engine to do so. I had to alter the render loop setup to get it to work and mess with the WndProc a bit, but it seems to be ok.

    This warning bothers me though.

    Using D3D to render for the editor is so nice because the map makers and level editors get a first-hand look at what everything will look like as they are creating them. Communicating to the engine from MFC is simple as well. So I get the benefits of a nice MFC GUI with a D3D renderer window.

    For scrolling I intercept the WM_SCROLL messages and tell the appropriate class in the engine to scroll the view and by what amounts. The actual window doesn't do any scrolling.
    Last edited by VirtualAce; 03-26-2006 at 04:52 AM.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    What standard library are you using? The one shipped with MSVC 7 isn't DLL-safe (you cannot share objects across module boundaries).
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm using MSVC 6 and the STL that came with it.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by Bubba
    I'm using MSVC 6 and the STL that came with it.
    It probably has the same problem, but I'm not 100% sure.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    It is just a warning, so it's not horrible, although I know you like to get listen to warnings (as a good programmer/engineer should). Have you tried building your DLL in a seperate project so that you don't have to worry about the _INSIDEDLL voodoo?

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It is in a separate project. If I don't use the voodoo , it will always assume dllexport. This allows me to build w/o having to define or change anything.

    But now I'm getting an undefined reference to InitD3D() which is part of the engine. The lib is in the link section so I'm not sure what's up.

    Don't ya just love libraries, DLL, and linker problems? The errors output from them are so informative. ::

  7. #7
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    If you have it in a seperate project, don't bother using those preproc defines. Have the project that makes the dll use the dllexport, and your other projects use the dllimport. I understand why you have those defines, but trying it this way might help you find out what's going on (ie give you a better/different warning)

    edit: you might have to have a seperate solution

    also, this would probalby be more of a help: http://msdn2.microsoft.com/en-us/library/esew7y1w.aspx

    the msdn's website gave more information that my installed msdn docs.

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by skorman00
    It was as I thought. You cannot use STL classes across DLL boundaries the way you're doing now.

    You should seriously consider upgrading your compiler (or at least the STL). It says on the page that Visual Studio 2005 STL doesn't have this problem and I know there are other STL you can download that also doesn't.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM