Skip to content

Fix build with musl - #6

Open
passgat wants to merge 1 commit into
CANopenTerm:mainfrom
passgat:fix_build_with_musl
Open

Fix build with musl#6
passgat wants to merge 1 commit into
CANopenTerm:mainfrom
passgat:fix_build_with_musl

Conversation

@passgat

@passgat passgat commented Aug 22, 2026

Copy link
Copy Markdown

This was exposed while integrating the package into Buildroot and testing its compilation with a musl-based toolchain:

CANvenient_SocketCAN.c: In function 'socketcan_open':
CANvenient_SocketCAN.c:186:24: error: storage size of 'tv' isn't known
186 | struct timeval tv;
| ^~
CANvenient_SocketCAN.c: In function 'socketcan_recv':
CANvenient_SocketCAN.c:364:36: error: invalid application of 'sizeof' to incomplete type 'struct timeval'
364 | char ctrlmsg[CMSG_SPACE(sizeof(struct timeval))];
| ^~~~~~
CANvenient_SocketCAN.c:406:28: error: invalid use of undefined type 'const struct timeval'
406 | *timestamp = tv->tv_sec * 1000000ULL + tv->tv_usec;
| ^~

Include <sys/time.h> to fix the build.

This was exposed while integrating the package into Buildroot and
testing its compilation with a musl-based toolchain:

  CANvenient_SocketCAN.c: In function 'socketcan_open':
  CANvenient_SocketCAN.c:186:24: error: storage size of 'tv' isn't known
    186 |         struct timeval tv;
        |                        ^~
  CANvenient_SocketCAN.c: In function 'socketcan_recv':
  CANvenient_SocketCAN.c:364:36: error: invalid application of 'sizeof' to incomplete type 'struct timeval'
    364 |     char ctrlmsg[CMSG_SPACE(sizeof(struct timeval))];
        |                                    ^~~~~~
  CANvenient_SocketCAN.c:406:28: error: invalid use of undefined type 'const struct timeval'
    406 |             *timestamp = tv->tv_sec * 1000000ULL + tv->tv_usec;
        |                            ^~

Include <sys/time.h> to fix the build.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

1 participant