On Tue, Dec 31, 2024 at 9:05 AM Antonio Borneo <borneo.anto...@gmail.com> wrote:
>
>
>
> On Mon, Dec 30, 2024, 23:07 Andrew Shelley <ashel...@btinternet.com> wrote:
>>
>> In file included from src/target/espressif/esp32_apptrace.c:25:
>>
>> ./src/helper/list.h:49:9: error: 'LIST_HEAD' macro redefined 
>> [-Werror,-Wmacro-redefined]
>>
>>    49 | #define LIST_HEAD(name) \
>>
>>       |         ^
>>
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/queue.h:465:9:
>>  note: previous definition is here
>>
>>   465 | #define LIST_HEAD(name, type)                                        
>>    \
>>
>>       |         ^
>>
>> 1 error generated.
>>
>> make[2]: *** [src/target/espressif/esp32_apptrace.lo] Error 1
>>
>> make[2]: *** Waiting for unfinished jobs....
>>
>> make[1]: *** [all-recursive] Error 1
>>
>> make: *** [all] Error 2
>>
>>
>>
>> Same macro name used in the OpenOCD list helper and one of the XCode headers.
>
>
> Thanks for reporting it.
>
> The file src/helper/list.h is almost a copy from Linux and I would like to 
> avoid diverging too much. But renaming this macro only should not be a big 
> problem.
> At first I want to have a look at the MacOS <sys/queue.h> and the equivalent 
> in other xBSD, if any.

Mistake in the reply above, src/helper/list.h is now a copy from BSD.
The Linux code has been dropped to use a more permissive license.

Then, the file <sys/queue.h> is part of GNU libc, it's not an abuse
from MacOS environment.
https://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/queue.h

Also openssl met this same issue recently
https://github.com/openssl/openssl/issues/25516
It is due to sys/queue.h being now included by some other system
include file. And this is probably MacOS specific.

Two proposals, feedback welcome:
1) use the same fix of openssl, that is renaming the OpenOCD macros
and keeping the file src/helper/list.h
2) drop src/helper/list.h and convert OpenOCD code to use sys/queue.h
from GNU libc

Proposal 1) slightly diverges from the original BSD code but still
keeps easy tracking and re-aligning with future changes in the BSD
reference code.

Proposal 2) looks more generic, better documented (see: "man queue",
"man circleq"), but <sys/queue.h> is not present in systems not using
GNU libc, e.g. MinGW.
We can detect, in configure, if <sys/queue.h> is present, and provide
a local copy as backup.
Today to keep OpenOCD code readable, we only use double linked
circular queues, that are the macros CIRCLEQ_xxx()
But we should modify too much code inside OpenOCD.
Maybe this should be considered as a future development only.

I understand that this issue only triggers a warning, so we can take
some time to decide.

Antonio

Reply via email to