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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:14:28+00:00 2026-05-23T03:14:28+00:00

Is it possible to declare a function with C linkage without it having external

  • 0

Is it possible to declare a function with C linkage without it having external linkage? When trying to compile

extern "C" static void f() {}

I get

f.cc:1: error: invalid use of 'static' in linkage specification

which makes sense, in a way. In namespace { extern "C" void f() {} }, the extern specifier seems to override the anonymous namespace’s restricted scope.

If this is not possible, does it matter when passing a function pointer to C?

  • 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-23T03:14:29+00:00Added an answer on May 23, 2026 at 3:14 am

    You can do

    extern "C" {
      static void f() {}
    }
    

    This will give the function f‘s type C linkage which in practice means that it uses the C calling convention on your platform. The function’s name will still have C++/internal linkage, because a language linkage specification only applies to function names of external linkage.

    If you specify the extern "C" directly on the declaration, the Standard specifies that the extern "C" is taken to be also a storage class specifier, so if you would add static, then you would get a conflict.

    Does it matter when passing a function pointer to C

    It can theoretically matter – an implementation is allowed to differ in behavior from calling a function whose type has C++ linkage to calling a function whose type has C linkage. I don’t know of implementation details though, just what the spec says about it. Best to follow the spec and you are safe.

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

Sidebar

Related Questions

declare function Error:toString($this as javaObject) as xs:string external; the previous binds a return String()
Apparently, it is possible to declare a function returning const void : const void
Why is not possible to initialize a property to a function when you declare
Is it possible to declare an instance of a generic without knowing the type
Is it possible to declare a variable in c++ without instantiating it? I want
I have a class, in which i declare a static function. I register this
Just wondering if it is possible to declare a function of an enumerated type
Is it possible to call a function without first fully defining it? When attempting
Is it possible to forward-declare a function in Python? I want to sort a
Is it possible to make an EXTERNAL FUNCTION as constant or immutable, so that

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.