Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix for the problem introduced by https://github.com/PDP-10/supdup/commit/d3f5019648cd14d96820599a838e4860b40a27d1#commitcomment-128203854 #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bictorv
Copy link
Contributor

@bictorv bictorv commented Sep 24, 2023

No description provided.

@larsbrinkhoff
Copy link
Member

Sorry, I already merged another fix one minute earlier.

@bictorv
Copy link
Contributor Author

bictorv commented Sep 25, 2023

Your solution also works, but I don't see why tcp.c or chaos.c would need supdup.h. The only definition which is used from supdup.h is USE_CHAOS_STREAM_SOCKET which wraps (essentially) all of chaos.c.

@larsbrinkhoff
Copy link
Member

supdup.h provides declarations of chaos_connect and tcp_connect, which are common to supcup.c, chaos.c, and tcp.c.

What I did was to move definitions out from supdup.h. It's a good idea to avoid definitions in header files, and in this case it was the cause of the problem.

@bictorv
Copy link
Contributor Author

bictorv commented Sep 25, 2023

But only supdup.c needs the declarations of chaos_connect and tcp_connect, not the others. (I completely agree about keeping variable definitions out of .h files, but a #define is a definition, isn't it?)

@larsbrinkhoff
Copy link
Member

It's a stylistic choice whether to have one big header file with all common declarations for the program, or many small header files each with a small scope. The former seemed to me natural with the style of supdup.c.

#define's define things but are commonly kept in header files since they are only preprocessor definitions, not C definitions (if I may use the term somewhat loosely; language lawyers might disagree). Since they don't generate any code or data at the definition site, they don't have any problem with multiple definitions.

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

Successfully merging this pull request may close these issues.

None yet

2 participants