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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:46:51+00:00 2026-05-19T21:46:51+00:00

How to declare a pointer to function in C, in order that the pointer

  • 0

How to declare a pointer to function in C, in order that the pointer itself is volatile.

static void volatile (* f_pointer)(void*);

static void (volatile * f_pointer)(void*);

static void (* volatile f_pointer)(void*);

Why I asking this? I read at http://wiki.answers.com/Q/Volatile_example_code_sample_coding_of_volatile_pointer about volatile pointers.

There are sometimes problems with volatile pointers and pointer-to volatile:

Now, it turns out that pointers to
volatile variables are very common.
Both of these declarations declare foo
to be a pointer to a volatile integer:

volatile int * foo; 
int volatile * foo; 

Volatile pointers to non-volatile variables are very rare (I think I’ve used them once),
but I’d better go ahead and give you the syntax:

int * volatile foo;

So, I want to get a volatile pointer to function not a pointer to “volatile” function.

Thanks

  • 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-19T21:46:51+00:00Added an answer on May 19, 2026 at 9:46 pm

    Think of the asterisk as a “barrier”. Qualifiers (const or volatile) closer to the variable name than the asterisk modify the pointer itself. Qualifiers farther way from the variable name than the asterisk modify what the pointer will refer to. In this case, therefore, you would have:

    static void * volatile f_pointer(void *);
    

    Except, of course, that you need parens to define a pointer to a function instead of declaring a function returning a pointer:

    static void (*volatile f_pointer)(void *);
    

    static is a storage class rather than a qualifier, so the same is not true in its case. You can only specify a storage class for the variable itself, not what it points at. There’s no such thing as a “pointer to extern int” or “pointer to static int”, only “pointer to int”. If you specify a storage class (static or extern), it always comes first.

    Other threads have discussed the relationship between threading and volatile so I won’t repeat that here beyond noting that this probably won’t be useful.

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

Sidebar

Related Questions

With respect to this question, we can declare a function that returns pointer to
I cannot figure the syntax to declare a function pointer as a static member.
All, this is my code //declare string pointer BSTR markup; //initialize markup to some
I declare a static char array, then I pass it to a function. How
There is a JDK function that, although the javadocs does not declare it as
I can't seem to declare a generic pointer to function. Having these 2 functions
I need to declare an array of pointers to functions like so: extern void
I am trying to use this code to define the APIs that are needed
I'm trying to write a function for a database class that is basically just
Declare @BadDecimal varchar(5) Set @BadDecimal = '4.5' Declare @GoodDecimal Decimal Set @GoodDecimal = @BadDecimal

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.