Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22031

How to warn about incompatible type for argument on void pointer in C?

$
0
0

In a example below, I want to know the call of func with a wrong type of argument - vptr, which should be called with an int pointer.

void func(int * ptr){
}
int main(){
    void * vptr;
    func(vptr);
}

GCC doesn't warn this type of warnings even with wall option. Is there any other options in gcc, or other programming tricks of finding out those bad manners of codes. Aside that, how about in cpp?

EDIT: VTT answered this is valid in C, but invalid in C++ with no other cast keywords like static_cast (see the other post in detail).


Viewing all articles
Browse latest Browse all 22031

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>