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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:11:34+00:00 2026-05-16T06:11:34+00:00

I have a function whose prototype is as follows: void foo(const char * data);

  • 0

I have a function whose prototype is as follows:

void foo(const char * data);

Elsewhere in my code, I have a global variable declared as follows

volatile char var[100];

Whenever I try to do this:

foo(var);

The compiler throws up the following error message:

Argument of type “volatile char *” is incompatible with parameter of type “const char *”

Why is that the case? As I understand it, the variable in my function is not allowed to change the pointer or its contents. I understand that because my global variable is volatile, it could potentially change at any time, but seeing as it is perfectly legal to have a volatile const variable, I don’t see why I am getting this compiler error.

Thanks

–Amr

  • 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-16T06:11:35+00:00Added an answer on May 16, 2026 at 6:11 am

    It’s because implicit conversions can add qualifiers to the target of pointer types, but not remove them. So if you want your function to be able to accept volatile and/or const qualified pointers, you must declare it with both:

    void foo(const volatile char * data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen a function whose prototype is: int myfunc(void** ppt) This function is
I have a function in my namespace, ns::foo , whose job is to dispatch
I passed a pointer ptr to a function whose prototype takes it as const
I have the following prototype JavaScript code Event.observe( window, 'load', function() { Event.observe( 'agreement',
I have a module that has a function whose prototype is similar to that
I have function whose signature is something like so: void someFunc(ifstream ifile) { This
I have a function whose return type is Table This code does not work.
I have to send the key code in hexadecimal to a function whose job
I have a function whose input argument can either be an element or a
i have build a small function whose work to get value in alert box

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.