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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:38:46+00:00 2026-06-15T09:38:46+00:00

Typically one includes standard library headers in C++ in the global namespace, outside of

  • 0

Typically one includes standard library headers in C++ in the global namespace, outside of any externs, like so:

#include <stdint.h>

int main() { }

But what’s specified to happen if you include a standard library header inside one? For example:

extern "C" {
#include <stdint.h>
}
int main() { }

or

extern "C++" {
#include <stdint.h>
}
int main() { }

Is it specified what should happen in either case, or is it implementation-defined or even undefined?

C++11 17.6.2.3p1 says that C++ standard library headers put stuff in extern "C++", but my tentative reading is that this doesn’t apply to C headers like <stdint.h>. C++11 17.6.2.2p3 says headers can only be #included outside of any “external declaration”; this phrase appears only this one place in C++11, so I’m not sure if it might apply here. (I’m assuming C99 has nothing to say about this.)

(For my particular case it isn’t an option to use C++’s <c*> standard headers, so I really need to know the semantics only for the old-school C headers.)

  • 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-15T09:38:48+00:00Added an answer on June 15, 2026 at 9:38 am

    The standard doesn’t say anything about C headers that are not part of C++. Previous to C++-11, stdint.h/cstdint was not part of C++. It’s up to that header how it behaves when included from C++ code.

    If you’re asking about C headers that are part of C++, the only difference between *.h and c* is that the former isn’t required to add its identifiers to the std namespace (it’s optional whether it does so or not,) while the latter is required to do so (and it can optionally also add them to the global namespace.) There’s no other difference. You shouldn’t include a standard *.h header inside an extern "C" block, as the headers themselves take care of using C linkage where needed.

    If you have non-standard C headers you want to include from C++ code, then you must inspect those headers to determine whether you need to include them extern "C" or not on a case by case basis.

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

Sidebar

Related Questions

Standard headers for C++ are typically installed in /usr/include/c++/4.x (in Linux). Since most of
In GWT one typically loads i18n strings using a interface like this: public interface
Typically interfaces that let you add listeners also include a remove method something like
How would one typically implement a service layer in an MVC architecture? Is it
How would one typically create a dynamic factory method in PHP? By dynamic factory
With my database upgrade scripts, I typically just have one long script that makes
I have a series of images. Each one is typically (but not always) similar
The typical Python threadpool will have a structure like this one: def run(self): while
Typically you start a service like this Intent i = new Intent(context,MessageService.class); context.startService(i); but
On a page of my web app I include an iframe. The iframe typically

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.