From 26010e1410faa0dcefc8d384872bc0210cc0be92 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 13 Aug 2013 22:16:20 -0700 Subject: [PATCH 1/1] threads: kill clang warnings about struct/class Thread We just need an opaque pointer for C, so we can retain the type safety for C++ by conditionally compiling a '__thread_identifier' type as 'class Thread' for C++. The warning: clang++ -MMD -MF .threads.o.d -fPIC -c threads.cc -Wall -g -O3 -Iinclude -I. In file included from schedule.cc:4: ./threads-model.h:41:1: warning: 'Thread' defined as a class here but previously declared as a struct [-Wmismatched-tags] class Thread { ^ include/threads.h:9:1: note: did you mean class here? struct Thread; /* actually, class; but this is safe */ ^~~~~~ class --- include/threads.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/threads.h b/include/threads.h index 66df5b1..f38be0a 100644 --- a/include/threads.h +++ b/include/threads.h @@ -6,7 +6,12 @@ #define __THREADS_H__ /* Forward declaration */ -struct Thread; /* actually, class; but this is safe */ +#ifdef __cplusplus +typedef class Thread *__thread_identifier; +#else +/* For C, we just need an opaque pointer */ +typedef void *__thread_identifier; +#endif #ifdef __cplusplus extern "C" { @@ -15,7 +20,7 @@ extern "C" { typedef void (*thrd_start_t)(void *); typedef struct { - struct Thread *priv; + __thread_identifier priv; } thrd_t; int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg); -- 2.34.1