Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMartins Mozeiko

Posted 14 December 2012 - 04:38 PM

SiCrane - I don't think it's true.
GCC (also Visual Studio) defines NULL like this: "#define NULL ((void *)0)" in stddef.h.
So:
c:\ test>type a.cpp

#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}

c:\ test>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

foo(NULL) correctly calls foo(void*).

#5Martins Mozeiko

Posted 14 December 2012 - 04:37 PM

SiCrane - I don't think it's true.
GCC (also Visual Studio) defines NULL like this: "#define NULL ((void *)0)" in stddef.h.
So:
c:\	est>type a.cpp

#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}

c:\	est>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

foo(NULL) correctly calls foo(void*).

#4Martins Mozeiko

Posted 14 December 2012 - 04:36 PM

SiCrane - I don't think it's true.
GCC defines NULL like this: "#define NULL ((void *)0)"
So:
c:\\test>type a.cpp

#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}

c:\\test>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

foo(NULL) correctly calls foo(void*).

#3Martins Mozeiko

Posted 14 December 2012 - 04:36 PM

SiCrane - I don't think it's true.
GCC defines NULL like this: "#define NULL ((void *)0)"
So:
c:\\test>type a.cpp

#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}

c:\\test>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

#2Martins Mozeiko

Posted 14 December 2012 - 04:35 PM

SiCrane - I don't think it's true.
c:\\test>type a.cpp
#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}
c:\\test>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

#1Martins Mozeiko

Posted 14 December 2012 - 04:34 PM

SiCrane - I don't think it's true.
c:	est>type a.cpp
#define NULL ((void*)0)
void foo(int);
void foo(void*);
int main()
{
  foo(NULL);
}
c:	est>g++ a.cpp
C:\Users\XXX\AppData\Local\Temp\ccAUKoxR.o:a.cpp:(.text+0x16): undefined reference to `foo(void*)'
collect2.exe: error: ld returned 1 exit status

PARTNERS