xiaoyeli / superlu_dist

Distributed memory, MPI based SuperLU
https://portal.nersc.gov/project/sparse/superlu/
Other
186 stars 64 forks source link

Compilation error with GCC: implicit declaration of function 'putenv' #169

Closed mathsen closed 1 month ago

mathsen commented 2 months ago

Hello,

when compiling current master branch with GCC 14.2.1. I get the following error:

TEST/pdtest.c:503:21: error: implicit declaration of function 'putenv'; did you mean 'getenv'? [-Wimplicit-function-declaration]
  503 |                     putenv(xenvstr);

Simply moving #define _XOPEN_SOURCE // C99 standard extension to support putenv() before #include <stdio.h> fixes the issue for me:

diff --git a/TEST/pdtest.c b/TEST/pdtest.c
index ec34166d..192aa87b 100644
--- a/TEST/pdtest.c
+++ b/TEST/pdtest.c
@@ -24,6 +24,7 @@ at the top-level directory.
  * File name:          pdtest.c
  * Purpose:             MAIN test program
  */
+#define _XOPEN_SOURCE // C99 standard extension to support putenv()
 #include <stdio.h>
 #include <stdlib.h>
 //#include <unistd.h>
@@ -36,8 +37,6 @@ at the top-level directory.
 #include "superlu_dist_config.h"
 #include "superlu_ddefs.h"

-#define _XOPEN_SOURCE // C99 standard extension to support putenv()
-
 #define NTESTS 1 /*5*/      /* Number of test types */
 #define NTRAN  2
 #define THRESH 20.0

Many greetings mathse

xiaoyeli commented 2 months ago

Thanks for your info. I pushed an update in master to reflect this change. It will be in next release.

mathsen commented 1 month ago

@xiaoyeli Thanks for the quick fix! I an confirm that I can build latest master without any issues using GCC 14.2.1.