Skip to content

Conversation

@victoryforce
Copy link
Collaborator

Currently, compiling darktable code with LLVM 20 fails with the following error:

In file included from C:/msys64/home/Victor/darktable/src/common/exif.cc:42:
In file included from C:/msys64/home/Victor/darktable/src/control/control.h:32:
In file included from C:/msys64/home/Victor/darktable/src/control/jobs.h:24:
In file included from C:/msys64/home/Victor/darktable/src/views/view.h:21:
In file included from C:/msys64/home/Victor/darktable/src/common/act_on.h:21:
C:/msys64/home/Victor/darktable/src/gui/gtk.h:407:104: fatal error: missing sentinel in function call [-Wsentinel]
  407 |   g_object_set(label, "halign", GTK_ALIGN_START, "xalign", 0.0f, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
      |                                                                                                        ^
      |                                                                                                        , nullptr

We can't use NULL here. The problem is that in this case the code ends up being included from a C++ source file (exif.cc), and in C++ (unlike plain C) NULL is defined as simply 0 or 0LL (which is an integer constant, but not a pointer type), while in plain C it is defined as ((void *)0).

LLVM 20 starts flagging this as a warning (which becomes an error in our build process), forcing sentinel to be a null pointer, not just a null value.

The need for sentinel to be a pointer type is documented in https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Common-Function-Attributes.html#index-sentinel-function-attribute:

A valid NULL in this context is defined as zero with any pointer type. If your system defines the NULL macro with an integer type then you need to add an explicit cast.

Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

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

Thanks!

(maybe you could have kept NULL : (void *)NULL).

@TurboGit TurboGit merged commit d41dbce into darktable-org:master Mar 30, 2025
6 checks passed
@TurboGit TurboGit added this to the 5.2 milestone Mar 30, 2025
@TurboGit TurboGit added bugfix pull request fixing a bug scope: codebase making darktable source code easier to manage labels Mar 30, 2025
@victoryforce victoryforce deleted the fix-llvm20-build branch March 30, 2025 10:54
@victoryforce
Copy link
Collaborator Author

(maybe you could have kept NULL : (void *)NULL).

Then readers of the code who know the definition of NULL in C will wonder why this is necessary. After all, in all other cases (when the code is included from the plain C source files), "(void *)NULL" will expand to "(void *)(void *)0".

I'd better try to write a compact explanation and add a comment with it. Just to document why our code has to look like this, departing from the established pattern.

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

Labels

bugfix pull request fixing a bug scope: codebase making darktable source code easier to manage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants