Skip to content

Cannot compile library due to _BSD_SOURCE wrong usage  #4301

@TeoGoddet

Description

@TeoGoddet

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

Metadata

Metadata

Assignees

Labels

L: C-SourcesIssue addresses Modelica/Resources/C-SourcesbugCritical/severe issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions