[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
Hello,
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
-I/home/trahay/Soft/opt/darshan/darshan-util/install/include
In file included from test_darshan-log-format.cpp:3:
/home/trahay/Soft/opt/darshan/darshan-util/install/include/darshan-log-format.h:135:29:
warning: ISO C++ forbids converting a string constant to ‘char*’
[-Wwrite-strings]
135 | X(DARSHAN_NULL_MOD, "NULL", DARSHAN_NULL_VER, NULL) \
| ^~~~~~
/home/trahay/Soft/opt/darshan/darshan-util/install/include/darshan-log-format.h:161:23:
note: in definition of macro ‘X’
161 | #define X(a, b, c, d) b,
| ^
/home/trahay/Soft/opt/darshan/darshan-util/install/include/darshan-log-format.h:164:5:
note: in expansion of macro ‘DARSHAN_MODULE_IDS’
164 | 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
darshan_module_names[]".
The attached patch fixes the problem.
François
-------------- 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[] =
{
DARSHAN_MODULE_IDS
};
More information about the Darshan-users
mailing list