Skip to content

Fix all -Wimplicit-function-declaration errors for GCC 14+#34

Open
P4o1o wants to merge 2 commits intoOpenMathLib:masterfrom
P4o1o:fix/implicit-function-declarations
Open

Fix all -Wimplicit-function-declaration errors for GCC 14+#34
P4o1o wants to merge 2 commits intoOpenMathLib:masterfrom
P4o1o:fix/implicit-function-declarations

Conversation

@P4o1o
Copy link

@P4o1o P4o1o commented Mar 6, 2026

Fixes #33

Problem

Starting with GCC 14, -Wimplicit-function-declaration was promoted from
warning to error by default. This breaks the OpenVML build on all modern
distributions shipping GCC 14+ (Fedora 40+, CentOS Stream 10, Ubuntu 24.10+,
Arch, etc.).

On GCC ≤ 13 these were only warnings, so the build would succeed and all
tests passed — masking the underlying bugs.

This PR fixes all three implicit declaration issues at once, so that
the build actually succeeds end-to-end on GCC 14+.

Changes

1. Fix typo sdqr_kdsqr_k (include/openvml_kernel.h)

The double-precision sqr kernel was declared as sdqr_k instead of dsqr_k.
Every other kernel in the project follows the naming convention
s<func>_k (float), d<func>_k (double), c<func>_k (complex float),
z<func>_k (complex double). For example: sadd_k/dadd_k,
ssub_k/dsub_k, spow_k/dpow_k.

The macros in openvml_macros.h correctly define DSQR_K as dsqr_k,
but the prototype in openvml_kernel.h declared sdqr_k — a simple
transposition of the "s" and "d" prefixes.

-void OpenVML_FUNCNAME(sdqr_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params);
+void OpenVML_FUNCNAME(dsqr_k)(VMLLONG n, double * a, double * b, double * y, double * z, double * other_params);

2. Fix exp10/exp10f implicit declarations (openvml_common.h + include reordering)

exp10() and exp10f() are GNU extensions. Their prototypes are only
exposed by <math.h> when _GNU_SOURCE is defined. The project never
defined this macro, so the prototypes were invisible to the compiler.

Approach: rather than sprinkling #define _GNU_SOURCE in each individual
source file, I defined it once in include/openvml_common.h, which is
the project-wide common header included (directly or transitively) by all
source files. This is the cleanest and most maintainable solution — any
future GNU extension usage will also be covered.

Additionally, several files in kernel/generic/ and reference/ had
<math.h> included before "openvml_kernel.h" (which transitively
includes openvml_common.h). This meant _GNU_SOURCE was not yet defined
when <math.h> was processed. I reordered the includes so that the
project's own headers come first:

-#include <math.h>
-#include "openvml_kernel.h"
+#include "openvml_kernel.h"
+#include <math.h>

This follows the widely accepted best practice of including project/local
headers before system headers, ensuring that project-wide defines are
active before any system header is parsed.

Affected files:

  • include/openvml_common.h (added #define _GNU_SOURCE)
  • kernel/generic/*.c (reordered includes where needed)
  • reference/vexp10.c (reordered includes)

3. Fix get_cycles implicit declaration (test/vml_util.c)

get_cycles() is defined in test/cycle.c and declared in test/cycle.h,
but test/cycle.h had a typo in the preprocessor definition.

 #ifdef _OPENVML_CYCLE_H_
+#ifndef _OPENVML_CYCLE_H_

Same error in test/openvml_timer.h

 #ifdef _OPENVML_TIMER_H_
+#ifndef _OPENVML_TIMER_H_

Why a single PR

All three issues produce the same compiler error (-Wimplicit-function-declaration)
and have the same root cause: GCC 14 turning this from a warning into an error.
Fixing only one would still leave the build broken on GCC 14+, so it makes
sense to address them together. The issue #33 is not truly resolved unless
all three are fixed.

Testing

  • Clean build (make clean && make) completes with zero
    -Wimplicit-function-declaration warnings/errors
  • All 63 run_vml_test tests pass
  • Tested on x86_64 Linux, GCC 13.3 (where these are still warnings,
    confirming backward compatibility)

P4o1o added 2 commits March 6, 2026 17:05
GCC 14 made implicit function declarations an error by default.
This broke the OpenVML build in three places:

1. include/openvml_kernel.h: typo 'sdqr_k' instead of 'dsqr_k'
   for the double-precision sqr kernel declaration.

2. kernel/generic/exp10_kernel.c, reference/vexp10.c: exp10/exp10f
   are GNU extensions requiring _GNU_SOURCE to be defined before
   including math.h.

3. test/vml_util.c: missing #include "cycle.h" for get_cycles()
   declaration.

On GCC <= 13 these were warnings; on GCC 14+ (Fedora 40+,
CentOS Stream 10, etc.) they are fatal errors.
GCC 14 made implicit function declarations an error by default.
This broke the OpenVML build in three places:

1. include/openvml_kernel.h: typo 'sdqr_k' instead of 'dsqr_k'
   for the double-precision sqr kernel declaration.

2. kernel/generic/exp10_kernel.c, reference/vexp10.c: exp10/exp10f
   are GNU extensions requiring _GNU_SOURCE to be defined before
   including math.h.

3. test/vml_util.c: missing #include "cycle.h" for get_cycles()
   declaration.

On GCC <= 13 these were warnings; on GCC 14+ (Fedora 40+,
CentOS Stream 10, etc.) they are fatal errors.
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.

Compile error

1 participant