[clinfo] 01/55: Cleanly compile with pedantic
Andreas Beckmann
anbe at moszumanska.debian.org
Sat Jan 13 14:39:58 UTC 2018
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository clinfo.
commit b25c4111cc2305521b3a0a8d775c2b38a64a3f7c
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date: Fri Apr 22 18:03:03 2016 +0200
Cleanly compile with pedantic
---
Makefile | 2 +-
src/clinfo.c | 13 ++++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 8c18fe6..88af306 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ ifeq ($(PLATFORM),Linux)
LDLIBS += -ldl
endif
-CFLAGS+=-std=c99 -g -Wall -Wextra
+CFLAGS+=-std=c99 -g -Wall -Wextra -pedantic
SPARSE ?= sparse
SPARSEFLAGS=-Wsparse-all -Wno-decl
diff --git a/src/clinfo.c b/src/clinfo.c
index e95d563..efeea3e 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -10,6 +10,13 @@
#define RTLD_DEFAULT ((void*)0)
#endif
+/* ISO C forbids assignments between function pointers and void pointers,
+ * but POSIX allows it. To compile without warnings even in -pedantic mode,
+ * we use this horrible trick to get a function address from
+ * clGetExtensionFunctionAddress
+ */
+#define PTR_FUNC_PTR *(void**)&
+
/* Load STDC format macros (PRI*), or define them
* for those crappy, non-standard compilers
*/
@@ -2222,7 +2229,7 @@ cl_uint checkNullGetDevices(void)
}
}
if (i == num_platforms) {
- sprintf(strbuf, "<error: platform 0x%p not found>", plat);
+ sprintf(strbuf, "<error: platform 0x%p not found>", (void*)plat);
}
}
printf(I1_STR "%s\n",
@@ -2333,7 +2340,7 @@ void checkNullCtxFromType(void)
break;
}
if (i == num_platforms) {
- sprintf(strbuf, "<error: platform 0x%p not found>", plat);
+ sprintf(strbuf, "<error: platform 0x%p not found>", (void*)plat);
break;
} else {
szval += sprintf(strbuf, "%s (%" PRIuS ")",
@@ -2535,7 +2542,7 @@ void oclIcdProps(void)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
- clGetICDLoaderInfoOCLICD = clGetExtensionFunctionAddress("clGetICDLoaderInfoOCLICD");
+ PTR_FUNC_PTR clGetICDLoaderInfoOCLICD = clGetExtensionFunctionAddress("clGetICDLoaderInfoOCLICD");
#ifdef _MSC_VER
#pragma warning(pop)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git
More information about the Pkg-opencl-commits
mailing list