How to get standard C and C++ working together? How to debug a DLL?

Discussion in 'C++' started by Christian Graf, Aug 11, 2003.

  1. Hi,

    (sorry if this post might occur two times, but I can't find my first
    one from yesterday evening in this group)

    I have a bigger VC++6.0 project which is successfully compiled into a
    DLL. I had to combine this code with my one which worked fine for
    itself. After integrating my code one into one of the classes the the
    compiler threw errors. They disappeared after the compiler option
    __STDC__ was removed. Apparently the larger project was build in full
    conformance with the ANSI C standard. My code is C++ code (and can't
    be rewritten), thus the errors when compiled with __STDC__ activated.
    An additional __ANSI_CPP__ is defined in the DLL project as well, but
    doesn't seem to harm or benefit to the build process of the combined
    project.

    The problem now is, that my DLL does compile without erros but doesn't
    work when used by an EXE. It simply crashes. As a DLL has no console
    output, how can I get some indication what goes wrong? How can I debug
    a DLL with VC++? And most importantly: How can I integrate ANSI C and
    VC++ in one project? Is there such a thing as guidelines, general
    rules or special compiler settings?

    Cheers
    Chris
    Christian Graf, Aug 11, 2003
    #1
    1. Advertising

  2. Christian Graf

    ak Guest

    On 11 Aug 2003 15:13:18 -0700, (Christian Graf)
    wrote:

    |The problem now is, that my DLL does compile without erros but doesn't
    |work when used by an EXE. It simply crashes. As a DLL has no console
    |output, how can I get some indication what goes wrong? How can I debug
    |a DLL with VC++? And most importantly: How can I integrate ANSI C and
    |VC++ in one project? Is there such a thing as guidelines, general
    |rules or special compiler settings?

    Since you are the author of the DLL it should be no problem to debug it,
    just specify the .EXE as startup for your DLL in the debug options.
    Alternatively you could build in trace output by using TRACE() / ATLTRACE() /
    OutputDebugString in your DLL and use DBGViEW from www.sysinternals.com
    to check the debug output.

    your exported functions in the DLL must bear non-mangled names by specifying
    them being extern "C" if they are to be used by a C program, there are also some
    rules what you can export to a C-program - check your online help.

    anyway try posting in microsoft.public.vc.language or any other suitable
    microsoft.public NGs for better help.

    hth
    Anders

    --
    ak @ workmail.com
    A wise man washes his hands after he pees. A wiser man doesn't pee on his hands.
    ak, Aug 12, 2003
    #2
    1. Advertising

  3. Christian Graf

    Emry Guest

    "Christian Graf" <> wrote in message
    news:...
    > Hi,
    >

    <snip>

    In most cases, if you simply just include the C code, and compile the entire
    thing as if it were C++, you should have no problems. Just make sure to
    include the right include files for the appropriate C functions.
    Emry, Aug 12, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    0
    Views:
    621
  2. hiwa
    Replies:
    3
    Views:
    979
  3. ringos75
    Replies:
    0
    Views:
    938
    ringos75
    Apr 14, 2005
  4. H. Simpson
    Replies:
    4
    Views:
    243
    H. Simpson
    Aug 3, 2004
  5. Guy

    standard and OOP together

    Guy, May 10, 2009, in forum: Perl Misc
    Replies:
    3
    Views:
    80
    Mordechai T. Abzug
    May 13, 2009
Loading...

Share This Page