[Darshan-users] Compilation problems when using darshan-log-format.h in C++

François Trahay francois.trahay at telecom-sudparis.eu
Thu Jan 23 06:39:34 CST 2020


I'm working on a C++ software that reads darshan files, and I face a 
compilation problem when compiling with g++. You can reproduce the 
problem with test_darshan-log-format.cpp:

$ cat test_darshan-log-format.cpp:

extern "C"
#include <darshan-log-format.h>

$ g++ -c test_darshan-log-format.cpp 
In file included from test_darshan-log-format.cpp:3:
warning: ISO C++ forbids converting a string constant to ‘char*’ 
   135 |     X(DARSHAN_NULL_MOD,     "NULL", DARSHAN_NULL_VER,       NULL) \
       |                             ^~~~~~
note: in definition of macro ‘X’
   161 | #define X(a, b, c, d) b,
       |                       ^
note: in expansion of macro ‘DARSHAN_MODULE_IDS’
       |     ^~~~~~~~~~~~~~~~~~


The problem comes from darshan-log-format.h that defines "static char * 
const darshan_module_names[]" instead of "static const char * const 

The attached patch fixes the problem.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_darshan-log-format.cpp
Type: text/x-c++src
Size: 47 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/darshan-users/attachments/20200123/8e6bce27/attachment.bin>
-------------- next part --------------
diff --git a/darshan-log-format.h b/darshan-log-format.h
index dc82ecd..0105bf2 100644
--- a/darshan-log-format.h
+++ b/darshan-log-format.h
@@ -159,7 +159,7 @@ typedef enum
 /* module name strings */
 #define X(a, b, c, d) b,
-static char * const darshan_module_names[] =
+static const char * const darshan_module_names[] =

More information about the Darshan-users mailing list