You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Function with Similar Name Found in Socket.h and File.h due to which When Closing File close function from socket.h gets called falsely and Program Hangs.
The text was updated successfully, but these errors were encountered:
rndalteem
changed the title
Conflict Betwenn close() function in Socket.h and File.h
Conflict Between close() function in Socket.h and File.h
Oct 16, 2021
possibly there is a simple solution to your problem: Define a macro after including one of Socket.h or File.h and rename the close()-function name by defining a macro. After that you include the remaining header file.
// Include socket.h and rename close function
include <socket.h>
#define socket_close() close()
// Now include file.h
include <file.h>
You can now use socket_close() to close a socket and close() to close a file handle.
Optionally you can change the second block to:
include <file.h>
#define file_close() close()
By doing so there is no possible misuse as both functions are named unambiguously,
Function with Similar Name Found in Socket.h and File.h due to which When Closing File close function from socket.h gets called falsely and Program Hangs.
The text was updated successfully, but these errors were encountered: