Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conflict Between close() function in Socket.h and File.h #116

Open
rndalteem opened this issue Oct 16, 2021 · 1 comment
Open

Conflict Between close() function in Socket.h and File.h #116

rndalteem opened this issue Oct 16, 2021 · 1 comment

Comments

@rndalteem
Copy link

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.

@rndalteem 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
@ulri-me
Copy link

ulri-me commented Feb 27, 2022

Hi rndalteem,

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,

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants