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

  • Home
  • SEARCH
  • 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 3397298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:30:42+00:00 2026-05-18T04:30:42+00:00

I am writing a cross platform shared library ( .so in linux and .dll

  • 0

I am writing a cross platform shared library (.so in linux and .dll in windows) using C. Currently when there is a error, library functions returns the proper error code and writes error information into the stderr. Library functions also emits some information and debug messages to stdout. This works well for console based clients.

Now this library will have client programs that uses GUI programmed using C++ & wxWidgets. I am wondering what would be the best practices in handling the errors and notifying it? Can a UI application access data coming to stdout and stderr on all platforms?

An alternative way I was thinking is the library initialization function initializes a structure which will have function pointers. All the functions on the library will take an instance of this structure and call the function pointers. This way the client can choose where to print the messages.

I am wondering what would be the obvious way to solve this? Any help would be great.

  • 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-05-18T04:30:42+00:00Added an answer on May 18, 2026 at 4:30 am

    Best practice (IMHO) is for a library to not print anything to stderr (or stdout), because they may not even be present. In addition to the GUI situation, you also have the use case of a server application that doesn’t have a “console”, and may want to be logging errors using a function like syslog().

    Some approaches for handling error information without printing it directly:

    • return a numeric error code, and provide a function for turning it into a string

    • return a struct/object error code, which contains additional information

    • provide a function on a “session” object that returns info about the last error

    • allow the caller to register a callback that’s invoked in the event of an error

    The one exception to the “don’t write to stderr from a library” rule that I’m reasonably comfortable with is if a library has a “debug mode” parameter that enables logging of detailed info to stderr.

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

Sidebar

Related Questions

I'm writing an cross-platform renderer. I want to use it on Windows, Linux, Android,
I'm considering writing a cross-platform desktop app, initially for Mac/Windows, but eventually for Linux
I'm writing cross platform C++ code (Windows, Mac). Is there a way to check
I'm writing a cross-platform code, which should compile at linux, windows, Mac OS. On
I'm writing some cross-platform code between Windows and Mac. If list::end() "returns an iterator
I'm writing C cross-platform library but eventually I've got error in my unittests, but
I am currently writing a cross platform app using the CoronaSDK and Lua. I
I am writing a program that is cross platform. There are a few spots
What are the best practices on writing a cross platform library in C++? My
I'm writing a cross-platform C++ program using Qt and I want to package/embed a

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.