Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#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