Qualifier not checked

A

Aad Rijnberg

Hi,

I had an unexpected problem with the following situation:
- a header file defining a prototype of a function:
void myfun(int * const x);
- a source file defining the implementation:
void myfun(int * x)
{
:
}

I would have expected that the compiler (gcc) warns that the qualifier in
the prototype and the implementation were different, but it does not. Is
there a compiler switch to turn this checking on? I tried
-pedantic, -Wcast-qual and -Wstrict-prototypes, but to no avail.

Any hints would be appreciated.

Aad Rijnberg
 
R

Robert Harris

What do you expect the qualifier to mean? Remember that changes to x in
the function will not affect the value of x in the caller.

Robert
 
M

Martin Dickopp

Aad Rijnberg said:
Hi,

I had an unexpected problem with the following situation:
- a header file defining a prototype of a function:
void myfun(int * const x);
- a source file defining the implementation:
void myfun(int * x)
{
:
}

I would have expected that the compiler (gcc) warns that the qualifier in
the prototype and the implementation were different, but it does not. Is
there a compiler switch to turn this checking on? I tried
-pedantic, -Wcast-qual and -Wstrict-prototypes, but to no avail.

Any hints would be appreciated.

This has been discussed just three days ago. Read the thread "Use
of const in parameter specification". You may also want to read the
tread "puts vs fputs" in comp.std.c.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top