Skip to content

Conversation

@trilkk
Copy link

@trilkk trilkk commented Jan 28, 2026

Description

Fix compilation errors on clang 19.1.7 on FreeBSD 15.0-RELEASE.

Motivation and Context

Apparently the current clang version on FreeBSD considers some earlier warnings as errors.
Additionally libprocstat.h requires several sys/ headers to be included prior to including it.

How Has This Been Tested?

The program has been compiled and starts on my local machine with FreeBSD 15.0-RELEASE-p1.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@mihawk90
Copy link
Contributor

Needs commit prefixes, see the contributing document

@trilkk trilkk force-pushed the freebsd-15-compilation-fix-2026-01-28 branch from 5293439 to e9a1d1e Compare January 28, 2026 21:51
@trilkk
Copy link
Author

trilkk commented Jan 28, 2026

Needs commit prefixes, see the contributing document

An attempt has been made. Force pushed.

@PatTheMav
Copy link
Member

Commit prefixes don't need to use the entire path, so for any plugin-related change the prefix plugins is sufficient (I'm working on an update to the contribution guidelines that make this more explicit).

Copy link
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

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

Can you provide the compiler error messages that lead you to make these changes?

I wonder specifically about the curl-related changes, whether they are indeed due to clang being more strict about narrowing of types or if this is due to more recent curl versions being more strict about the type correctness of curl_easy_setopt.

@trilkk trilkk force-pushed the freebsd-15-compilation-fix-2026-01-28 branch from e9a1d1e to fb35367 Compare January 30, 2026 18:00
@trilkk
Copy link
Author

trilkk commented Jan 30, 2026

Another attempt was made.

There are quite a lot of errors:

[ 27%] Building C object plugins/linux-v4l2/CMakeFiles/linux-v4l2.dir/v4l2-helpers.c.o
/usr/local/src/obs-studio/plugins/linux-v4l2/v4l2-helpers.c:80:68: error: format specifies type 'long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Werror,-Wformat]
   80 |         blog(LOG_DEBUG, "attempting to read buffer data for %ld buffers", buf_data->count);
      |                                                             ~~~           ^~~~~~~~~~~~~~~
      |                                                             %u
...
/usr/local/src/obs-studio/plugins/linux-v4l2/v4l2-helpers.c:87:66: error: format specifies type 'long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Werror,-Wformat]
   87 |                         blog(LOG_DEBUG, "failed to read buffer data for buffer #%ld", i);
      |                                                                                 ~~~   ^
      |                                                                                 %u
...
/usr/local/src/obs-studio/plugins/linux-v4l2/v4l2-helpers.c:90:94: error: format specifies type 'long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Werror,-Wformat]
   90 |                              "query buf #%ld info: ts: %06ld buf id #%d, flags 0x%08X, seq #%d, len %d, used %d", i,
      |                                          ~~~                                                                      ^
      |                                          %u
...
/usr/local/src/obs-studio/shared/file-updater/file-updater/file-updater.c:114:2: error: call to 'Wcurl_easy_setopt_err_long' declared with 'warning' attribute: curl_easy_setopt expects a long argument [-Werror,-Wattribute-warning]
  114 |         curl_easy_setopt(info->curl, CURLOPT_NOSIGNAL, 1);
      |         ^
...
/usr/local/src/obs-studio/shared/file-updater/file-updater/file-updater.c:113:2: error: call to 'Wcurl_easy_setopt_err_long' declared with 'warning' attribute: curl_easy_setopt expects a long argument [-Werror,-Wattribute-warning]
  113 |         curl_easy_setopt(info->curl, CURLOPT_FAILONERROR, true);
      |         ^
...
/usr/local/src/obs-studio/shared/file-updater/file-updater/file-updater.c:111:2: error: call to 'Wcurl_easy_setopt_err_write_callback' declared with 'warning' attribute: curl_easy_setopt expects a curl_write_callback argument [-Werror,-Wattribute-warning]
  111 |         curl_easy_setopt(info->curl, CURLOPT_WRITEFUNCTION, http_write);
      |         ^
...
/usr/local/src/obs-studio/shared/file-updater/file-updater/file-updater.c:120:3: error: call to 'Wcurl_easy_setopt_err_write_callback' declared with 'warning' attribute: curl_easy_setopt expects a curl_write_callback argument [-Werror,-Wattribute-warning]
  120 |                 curl_easy_setopt(info->curl, CURLOPT_HEADERFUNCTION, http_header);
      |                 ^
...
usr/local/src/obs-studio/plugins/rtmp-services/service-specific/nimotv.c:87:2: error: call to 'Wcurl_easy_setopt_err_long' declared with 'warning' attribute: curl_easy_setopt expects a long argument [-Werror,-Wattribute-warning]
   87 |         curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, true);
      |         ^
...
/usr/local/src/obs-studio/plugins/rtmp-services/service-specific/showroom.c:116:2: error: call to 'Wcurl_easy_setopt_err_long' declared with 'warning' attribute: curl_easy_setopt expects a long argument [-Werror,-Wattribute-warning]
  116 |         curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, true);
      |         ^
...
In file included from /usr/local/src/obs-studio/frontend/utility/platform-x11.cpp:43:
/usr/include/libprocstat.h:128:2: error: unknown type name 'STAILQ_ENTRY'
  128 |         STAILQ_ENTRY(filestat)  next;
      |         ^
/usr/include/libprocstat.h:128:24: error: expected ';' at end of declaration list
  128 |         STAILQ_ENTRY(filestat)  next;
      |                               ^
/usr/include/libprocstat.h:139:19: error: use of undeclared identifier 'SPECNAMELEN'
  139 |         char            vn_devname[SPECNAMELEN + 1];
      |                                    ^
/usr/include/libprocstat.h:143:16: error: use of undeclared identifier 'SPECNAMELEN'
  143 |         char            devname[SPECNAMELEN + 1];
      |                                 ^
/usr/include/libprocstat.h:166:26: error: field has incomplete type 'struct sockaddr_storage'
  166 |         struct sockaddr_storage sa_local;       /* Socket address. */
      |                                 ^
/usr/include/libprocstat.h:166:9: note: forward declaration of 'sockaddr_storage'
  166 |         struct sockaddr_storage sa_local;       /* Socket address. */
      |                ^
/usr/include/libprocstat.h:167:26: error: field has incomplete type 'struct sockaddr_storage'
  167 |         struct sockaddr_storage sa_peer;        /* Peer address. */
      |                                 ^
/usr/include/libprocstat.h:166:9: note: forward declaration of 'sockaddr_storage'
  166 |         struct sockaddr_storage sa_local;       /* Socket address. */
      |                ^
/usr/include/libprocstat.h:174:13: error: unknown type name 'filestat_list'
  174 | STAILQ_HEAD(filestat_list, filestat);
      |             ^
/usr/include/libprocstat.h:174:1: error: a type specifier is required for all declarations
  174 | STAILQ_HEAD(filestat_list, filestat);
      | ^
/usr/include/libprocstat.h:187:2: error: unknown type name 'STAILQ_ENTRY'
  187 |         STAILQ_ENTRY(advlock)   next;
      |         ^
/usr/include/libprocstat.h:187:23: error: expected ';' at end of declaration list
  187 |         STAILQ_ENTRY(advlock)   next;
      |                              ^
/usr/include/libprocstat.h:197:13: error: unknown type name 'advlock_list'
  197 | STAILQ_HEAD(advlock_list, advlock);
      |             ^
/usr/include/libprocstat.h:197:1: error: a type specifier is required for all declarations
  197 | STAILQ_HEAD(advlock_list, advlock);
      | ^

@PatTheMav
Copy link
Member

Thanks, that is helpful.

Some issues are uncontroversial:

  • Using the %ld type specifier for uint_fast32_t was always "wrong" because the actual size of the underlying int is architecture- and implementation specific (it can be 32-bit on one machine, might end up being 64-bit on another).
    • Instead of casting the type to long (which can work as long as the standard library uses LP64 and not LLP64) the specific macro definition PRIuFAST32 from inttypes.h should be used here (as much as I dislike their use in general)
  • The include changes for libprocstat.h are annoying but correct (per the associated man page).
  • The cURL errors are interesting, particularly because they are not raised on any other platform.

My hunch is that this might be due to curl/curl#17955 which was merged in December, so any sufficiently recent FreeBSD (or any other *NIX using clang) will now start to emit these warnings. That doesn't explain why we don't get those same warnings on Ubuntu already which uses a sufficiently modern gcc, but well..

@trilkk trilkk force-pushed the freebsd-15-compilation-fix-2026-01-28 branch from fb35367 to 82d3f79 Compare February 3, 2026 16:56
@trilkk trilkk force-pushed the freebsd-15-compilation-fix-2026-01-28 branch from 82d3f79 to ed145dd Compare February 3, 2026 16:58
@trilkk
Copy link
Author

trilkk commented Feb 3, 2026

Thanks for the review and comments.
Force-pushed again.

struct v4l2_buffer buf;

blog(LOG_DEBUG, "attempting to read buffer data for %ld buffers", buf_data->count);
blog(LOG_DEBUG, "attempting to read buffer data for %ld buffers", (PRIuFAST32)buf_data->count);
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised this didn't require including the inttypes header?

Copy link
Author

Choose a reason for hiding this comment

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

Somewhat surprised too, but I first tried without and it compiled just fine.

Seeing it went through your CI on all platforms, some other header must recursively include inttypes.

Copy link
Member

Choose a reason for hiding this comment

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

Seems so, but I would prefer if this compilation unit would include it explicitly, because the code in v4l2-helpers.c requires that macro to exist and it probably should not rely on it being transitively included somewhere (because once that "other" header chooses to stop using it, the code here would just break for no obvious reason).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants