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

Cannot compile library due to _BSD_SOURCE wrong usage #4301

Open
TeoGoddet opened this issue Feb 7, 2024 · 4 comments · May be fixed by #4302
Open

Cannot compile library due to _BSD_SOURCE wrong usage #4301

TeoGoddet opened this issue Feb 7, 2024 · 4 comments · May be fixed by #4302
Assignees
Labels
bug Critical/severe issue L: C-Sources Issue addresses Modelica/Resources/C-Sources
Milestone

Comments

@TeoGoddet
Copy link

TeoGoddet commented Feb 7, 2024

Hello,
I'm not a C expert, but I'm having problem compiling when I include open62541 lib (the amalgamated single file)

The error I have is

/mnt/c/Program Files/Dassault Systemes/B426_Cloud/win_b64/resources/Dymola/source/ModelicaInternal.c: In function ‘ModelicaInternal_fullPathName’:
/mnt/c/Program Files/Dassault Systemes/B426_Cloud/win_b64/resources/Dymola/source/ModelicaInternal.c:609:37: error: operator '||' has no left operand

line 609 looks like that in my dymola install :
#if defined(_WIN32) || (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || (_POSIX_VERSION >= 200112L))
The concerned line in the actual lib seems this one :

#elif (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L)

I think this occur because the _BSD_SOURCE define is empty because of this line in my lib :
https://github.com/open62541/open62541/blob/6115a47125d7e6ccd77488b8572807171adb0602/tools/ua-tool/ua.c#L18

open62541 seems legit to define _BSD_SOURCE empty
see https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_13.html

I would suggest replacing _BSD_SOURCE by defined(_BSD_SOURCE) in ModelicaInternal.c
I can open a MR is it seem the right fix

Note that there is three occurence of _BSD_SOURCE to fix

@TeoGoddet TeoGoddet changed the title Cannot compile library using _BSD_SOURCE due to wrong usage Cannot compile library using due to _BSD_SOURCE wrong usage Feb 7, 2024
@TeoGoddet
Copy link
Author

defined(_BSD_SOURCE) resulted in error related "realpath" not existing
I replaced _BSD_SOURCE by 0 and it compiled

@beutlich
Copy link
Member

beutlich commented Feb 8, 2024

I can open a MR is it seem the right fix

Thanks for reporting. Your PR would be appreciated.

@beutlich beutlich added the L: C-Sources Issue addresses Modelica/Resources/C-Sources label Feb 8, 2024
@TeoGoddet
Copy link
Author

@beutlich I can open a PR but i'm not confident enough in C and Modelica to be able to say that this fix is legitim
I see you made this commit in 2020, are you able to confirm my intuition ?

@beutlich beutlich self-assigned this Feb 8, 2024
@beutlich beutlich added the bug Critical/severe issue label Feb 8, 2024
@beutlich beutlich added this to the MSL4.1.0 milestone Feb 8, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Feb 8, 2024
@beutlich beutlich linked a pull request Feb 8, 2024 that will close this issue
@beutlich
Copy link
Member

beutlich commented Feb 8, 2024

@beutlich I can open a PR but i'm not confident enough in C and Modelica to be able to say that this fix is legitim I see you made this commit in 2020, are you able to confirm my intuition ?

@TeoGoddet I created #4302. If you have a chance to test you can give a review comment there.

@beutlich beutlich changed the title Cannot compile library using due to _BSD_SOURCE wrong usage Cannot compile library due to _BSD_SOURCE wrong usage Feb 8, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Feb 15, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Feb 27, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Mar 13, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Mar 14, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Mar 27, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Mar 29, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue May 21, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue May 22, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue May 28, 2024
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Critical/severe issue L: C-Sources Issue addresses Modelica/Resources/C-Sources
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants