Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Incompatible pointer type

Name: Anonymous 2009-06-09 18:31

Why does gcc bitch about incompatible pointer types?
A variable int number;
A function func(int *number);
And a function call like this func(&number);

Compiles fine, and works fine. But when I change the type, for example to uint16_t number; func(uint16_t *number); gcc throws a warning about incompatible pointer type.

Does gcc hate me?

Name: Anonymous 2009-06-09 20:04

It's just you:

#include <iostream>
#include <stdint.h>

using namespace std;

void foo(uint16_t* pf)
{
  cout << *pf << endl;
}

int main() {
  uint16_t foobar = 42;
  foo(&foobar);
}

NPP_SAVE: C:\Documents and Settings\James\Desktop\test.cpp
SET: Compiler = run@.cpp
$(COMPILER) = run@.cpp
NPP_EXEC: "run@.cpp"
g++ "C:\Documents and Settings\James\Desktop\test.cpp"  -std=c++0x -o "C:\Documents and Settings\James\Desktop\test.exe"
Process started >>>
<<< Process finished.
"C:\Documents and Settings\James\Desktop\test.exe"
Process started >>>
42
<<< Process finished.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List