By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,474 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

ISO C++ forbids declaration of ` pthread_cond_destroy' with no type

100+
P: 365
I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling in Linux with GCC.


pthread_cond_signal(&(receiverConf[numberofReceivers]->receive_q_cond));
pthread_cond_destroy(&(receiverConf[numberofReceivers]->receive_q_cond));
pthread_mutex_destroy(&(receiverConf[numberofReceivers]->receive_q_lock));

Main.cpp:545: ISO C++ forbids declaration of ` pthread_cond_signal' with no type
Main.cpp:545: `int pthread_cond_signal' redeclared as different kind of symbol
/usr/include/pthread.h:398: previous declaration of `int
pthread_cond_signal(pthread_cond_t*)'
Main.cpp:545: invalid conversion from `pthread_cond_t* ' to `int'

Main.cpp:546: ISO C++ forbids declaration of ` pthread_cond_destroy' with no type
Main.cpp:546: `int pthread_cond_destroy' redeclared as different kind of symbol
/usr/include/pthread.h:395: previous declaration of `int pthread_cond_destroy(pthread_cond_t*)'
Main.cpp:546: invalid conversion from `pthread_cond_t* ' to `int'

Main.cpp:547: ISO C++ forbids declaration of ` pthread_mutex_destroy' with no type
Main.cpp:547: `int pthread_mutex_destroy' redeclared as different kind of symbol
/usr/include/pthread.h:336: previous declaration of `int
pthread_mutex_destroy(pthread_mutex_t*)'
Main.cpp:547: invalid conversion from ` pthread_mutex_t*' to `int'



--------------------------------------------

int val123;



val123 = pthread_cond_signal((pthread_cond_t *)&(receiverConf[numberofReceivers]->receive_q_cond));
val123 = pthread_cond_destroy(&(receiverConf[numberofReceivers]->receive_q_cond));
val123 = pthread_mutex_destroy(&(receiverConf[numberofReceivers]->receive_q_lock));


Main.cpp:545: ISO C++ forbids declaration of `val123' with no type
Main.cpp:545: redefinition of `int val123'
Main.cpp:546: ISO C++ forbids declaration of `val123' with no type
Main.cpp:546: redefinition of `int val123'
Main.cpp:545: `int val123' previously defined here
Main.cpp:547: ISO C++ forbids declaration of `val123' with no type
Main.cpp:547: redefinition of `int val123'
Main.cpp:546: `int val123' previously defined here
Nov 26 '09 #1
Share this Question
Share on Google+
10 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
C++ does not support default-int. You have to actually specify the type or say void.
Nov 26 '09 #2

100+
P: 365
Do I have to redeclare pthread_cond_signal as void?. I wanted to use pthread lkibs, this is code is originally written in Windows, I am porting to Linux, since it is cpp file, I am compiling iwth g++ compiler.

This is already declared in pthread.h file as:
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex) __THROW;
Nov 27 '09 #3

100+
P: 687
Where is this
pthread_cond_signal(&(receiverConf[numberofReceivers]->receive_q_cond));

line located? It looks like it's outside of function and is treated as (re-)declaration of function (without return type) and compiler doesn't like it -
:545: ISO C++ forbids declaration of ` pthread_cond_signal' with no type
Nov 27 '09 #4

100+
P: 365
I am just calling this standard pthread_cond_signal() part of pthreads, do I have to declare this again in my Main.cpp file as extern?.
Nov 28 '09 #5

weaknessforcats
Expert Mod 5K+
P: 9,197
You must include your pthread.h file in every .c file since each .c file is a separate compilation. The linker merges all of the object files into the executable.
Nov 28 '09 #6

100+
P: 365
I have Main.cpp file, in the beginning I did include pthread.cpp like below, I am trying to compile this file with g++ command like below, I need to generate .o file first, later I need to make shared lib with this, but first I am trying to compile this .cpp file, I am getting the above errors:

#include <pthread.h>


g++ -g -O2 -Wall -I. -Iinclude -fPIC -c Main.cpp
Nov 28 '09 #7

Banfa
Expert Mod 5K+
P: 8,916
The lines of code you have posted all look fine therefore the error must be in something you didn't post. It is very hard to diagnose an error in code you can't see however your code appears to be over 500 lines long and we don't really want to see all that.

I suggest you attempt to reduce your code to the minimum compilable unit that still produces the error and then post that.
Nov 28 '09 #8

100+
P: 365
thank you sir, let me reduce the size and make it minimum and compile.
Nov 29 '09 #9

100+
P: 365
I had similar call somewhere else, that code as compiling, no problem at all, I am not getting this error for those lines, but only in this function I am getting this error, what I did was I declared just like that working code, then I compiled, it says "not declared in scope", but I declared within function, also I moved to global, no luck at all

Main.cpp:564: `cfgPtr22' was not declared in this
scope
Main.cpp:564: ISO C++ forbids declaration of `
pthread_cond_signal' with no type
Main.cpp:564: `int pthread_cond_signal' redeclared as
different kind of symbol
/usr/include/pthread.h:398: previous declaration of `int
pthread_cond_signal(pthread_cond_t*)'
Main.cpp:566: ISO C++ forbids declaration of `
pthread_cond_destroy' with no type
Nov 29 '09 #10

weaknessforcats
Expert Mod 5K+
P: 9,197
Maybe you could post your code for the functoin that contains line 564?
Nov 29 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.