Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Conversation

a-wai
Copy link
Contributor

@a-wai a-wai commented Jul 26, 2020

With GCC 10, HFUJabberStreamDataTable being declared in a header file
leads to the creation of 2 objects with that name: one when compiling
hfu_disco.c, the other one when compiling jabber_http_file_upload.c.

This results in link-time errors, which can be fixed by declaring
HFUJabberStreamDataTable as extern.

With GCC 10, `HFUJabberStreamDataTable` being declared in a header file 
leads to the creation of 2 objects with that name: one when compiling 
`hfu_disco.c`, the other one when compiling `jabber_http_file_upload.c`.

This results in link-time errors, which can be fixed by declaring 
`HFUJabberStreamDataTable` as `extern`.
Copy link
Owner

@Junker Junker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you redefine HFUJabberStreamDataTable in src/jabber_http_file_upload.c ?
Seems it's not necessary with extern.

@a-wai
Copy link
Contributor Author

a-wai commented Jul 26, 2020

Not defining HFUJabberStreamDataTable in the .c file would indeed work, at least with gcc >= 9, but I wouldn't consider it a good practice: extern means it's a declaration (pretty much like a function declaration in a header file), but proper C requires a corresponding definition somewhere, usually in a source file (again, very much like you would do with a function).

gcc seems to handle the lack of proper definition without complaining, but in order to avoid potential issues with other compilers, I think it's best to have HFUJabberStreamDataTable defined in src/jabber_http_file_upload.c

@githubDante githubDante mentioned this pull request Jul 28, 2020
@Junker Junker merged commit d4af654 into Junker:master Jul 28, 2020
@Junker
Copy link
Owner

Junker commented Jul 28, 2020

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants