Computer Science Canada

[Warning] Converting NULL pointer type to NULL

Author:  QuantumPhysics [ Sat Dec 29, 2012 12:20 pm ]
Post subject:  [Warning] Converting NULL pointer type to NULL

int nBytesOut = NULL;
int nBytesIn = NULL;

Is there a way to bypass this warning without setting the variable to a pointer? For my case I need to keep the same variable NULL and also an integer without setting it a pointer value.

Author:  Dreadnought [ Sat Dec 29, 2012 1:37 pm ]
Post subject:  Re: [Warning] Converting NULL pointer type to NULL

You can cast the pointer to an integer.
C:
int myInt = (int)myPointer;


Also, depending on the size of pointer of your machine you may want to consider using long.

Author:  DemonWasp [ Sat Dec 29, 2012 2:14 pm ]
Post subject:  RE:[Warning] Converting NULL pointer type to NULL

I think the far better question here is "what are you doing?"

Why are you trying to set a non-nullable type (such as int) to NULL? That's like trying to drive a banana.

Since NULL is (usually) 0, are you sure you don't mean "int nBytesOut = 0;" ?

Author:  Ultrahex [ Sat Dec 29, 2012 3:26 pm ]
Post subject:  Re: [Warning] Converting NULL pointer type to NULL

I am guessing you actually meant to do one of these:

c:
int *foo = NULL;

or

c:
void *foo = NULL;


depending on what you are doing.

Author:  QuantumPhysics [ Sat Dec 29, 2012 5:40 pm ]
Post subject:  RE:[Warning] Converting NULL pointer type to NULL

Nevermind, using typedef solved my problem.

Thank you anyways. Smile
I am making a type of virus. Only for EDUCATIONAL purposes. I will be testing it on my own system/network.

Author:  QuantumPhysics [ Sat Dec 29, 2012 9:23 pm ]
Post subject:  RE:[Warning] Converting NULL pointer type to NULL

Okay guys, now I am getting a bunch of linker errors. I have been working on it for 27 hours now... I am almost finished and this happens. The strange part is these errors only sign towards the winsock2 library... all the errors are from syntax I use in my program from that library. Please help me understand why, thanks Smile

Here are the errors:
[Linker Error] undefined reference to 'WSACleanup@0'
[Linker Error] undefined reference to 'WSAStarup@8'
[Linker Error] undefined reference to 'inet_addr@4'
[Linker Error] undefined reference to 'inet_ntoa@4'
[Linker Error] undefined reference to 'gethostbyname@4'
[Linker Error] undefined reference to 'inet_ntoa@4'
[Linker Error] undefined reference to 'htons@4'
[Linker Error] undefined reference to 'socket@12'
[Linker Error] undefined reference to 'WSAGetLastError@0'
[Linker Error] undefined reference to 'connect@12'
[Linker Error] undefined reference to 'send@16'
[Linker Error] undefined reference to 'recv@16'
[Linker Error] undefined reference to 'closesocket@4'
ld returned 1 exit status

Can anyone tell me the source of error? I Am very confused. I include winsock2.h and signal.h

Author:  bl0ckeduser [ Sun Dec 30, 2012 9:54 pm ]
Post subject:  Re: RE:[Warning] Converting NULL pointer type to NULL

QuantumPhysics @ Sat Dec 29, 2012 9:23 pm wrote:
Can anyone tell me the source of error? I Am very confused. I include winsock2.h and signal.h


I think you forgot to link the relevant libraries. Including headers is not sufficient. If you provide the name of the compiler you use, the command line you use to compile, what these missing libraries are, etc., people who know the systems in question well may be able to provide further assistance.


: