Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:42:32+00:00 2026-06-09T04:42:32+00:00

I’m creating a windows DLL library that contains a logging class, the log function

  • 0

I’m creating a windows DLL library that contains a logging class, the log function in that class simply calls fprintf like this for testing purposes:

fprintf(stderr, “DEBUG: %s\n”, “Hello”);

Now this call works fine if i use it from any function in any file in my other project (that uses the library) but if i put it anywhere in my library with the logging class it simply wont print anything.
I can see it runs the function correctly (using a simple exit(0); to test).

Now i’m still kinda new to the whole Library concept in c/c++ so there might be something i just don’t understand, but otherwise i don’t know why it doesn’t work.

I tried searching here and on google, but i couldn’t find anyone else with the same exact problem.
I use VC++ 2010

EDIT: I got the idea of passing the filepointer instead of just using stderr from the library, this causes an exception to be thrown however (the _tmpfname pointer of the file is NULL at the time of the throw, which im not sure is correct)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:42:33+00:00Added an answer on June 9, 2026 at 4:42 am

    I would avoid doing this for any production code (it’s ok for testing though). The standard I/O streams belong to the application, and the DLLs are guests in the house. If you want to provide debug output, allow the application to setup a callback function for logging, e.g.:

    // In your DLL's header file:
    typedef void (*LogFunc)(const char *, ...);
    void DLLEXPORT SetLogFunction(LogFunc logFunc);
    
    // In your DLL's source file:
    LogFunc g_LogFunc;
    void DLLEXPORT SetLogFunction(LogFunc logFunc)
    {
        g_LogFunc = logFunc;
    }
    
    ...
    // Then, instead of calling fprintf(stderr, "blah"), do this:
    g_LogFunc("blah");
    

    If you’re just doing this for testing, you can write directly to stderr, but keep in mind that the DLL and the application must be linked against the same version of the C runtime in order for that to work. The C runtime is itself a DLL, and if your DLL and the application specify different versions of the C runtime, you’ll end up loading two separate copies of the C runtime into memory, each with their own idea of what stderr means. When they’re different, bad stuff happens.

    In Visual Studio, to set the C runtime library you’re using, open up your project settings and go to Configuration Properties → C/C++ → Code Generation → Runtime Library and make sure that both the DLL and the application are set to the exact same value (typically “Multi-threaded DLL (/MD)” or “Multi-threaded Debug DLL (/MDd)”, depending on whether you’re building a Debug or Release build).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.