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 8331555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:27:00+00:00 2026-06-09T02:27:00+00:00

In my code I bring the OpenSSL headers in in a namespace, like this:

  • 0

In my code I bring the OpenSSL headers in in a namespace, like this:

#include <cstdio>
namespace OpenSSL {
    #include <openssl/ssl.h>
    #include <openssl/err.h>
}

But I’ve just discovered that this seems to cause things to explode if I try to do that when working with Boost ASIO, which has OpenSSL support, but appears to bring the OpenSSL symbols in to the global namespace. Is there anything I can do about this, or do I just have to leave all of the OpenSSL library’s symbols in the global namespace?

I did just think of trying a “using namespace OpenSSL” in the offending file after including my header, but that unfortunately causes errors such as:

/usr/include/openssl/x509v3.h:83:13: error: reference to ‘v3_ext_ctx’ is ambiguous
/usr/include/openssl/x509v3.h:71:8: error: candidates are: struct v3_ext_ctx
/usr/include/openssl/ossl_typ.h:160:16: error:                 struct OpenSSL::v3_ext_ctx

(Note that OpenSSL is a C library, not a C++ library, and thus the original functions are not in any namespace until brought in to a C++ compilation unit. My technique is recommended by Stroustrup in his book The C++ Programming Language, Special Edition. From section 9.5, “Advice”: “[8] #include C headers in namespaces to avoid global names; §8.2.9.1, §9.2.2.”

  • 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-09T02:27:01+00:00Added an answer on June 9, 2026 at 2:27 am

    So the issue seems to be this: OpenSSL’s symbols can be brought in only once; a second #include of them will have no effect due to the include guards. That means that they can be brought in to only one namespace within a compilation unit.

    Thus, if you’re going to work with Boost.ASIO in your compilation unit, which requires them to be in the global namespace, you’ll have either to bring them in to the global namespace yourself (before you #include <boost/asio.hpp> or let #include <boost/asio.hpp> do that.

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

Sidebar

Related Questions

I'm using this code to bring up my window: [self.window makeKeyAndOrderFront:self]; [self.window setOrderedIndex:0]; But
I am currently using this code to bring up an info window -(IBAction)showInfo:(id)sender {
I have the following code, which compiles but doesn't bring back any data. Here
i.e. I want to bring this in my code: static BOOL MyConstantBool = YES;
I'm trying to use the below code to bring back all records that are
At this moment i am using the code bellow to bring up a dialog
I'd like to use the OpenSSL library to decrypt some AES data. The code
Javascript already support extension so what real supplement advantages would jstraits http://code.google.com/p/jstraits/ would bring
It seems that runClasses() doesn't terminate the code being tested even after the test
Having a hard time figuring out why this alert code is being called once

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.