472,146 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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

365 100+
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
10 4162
weaknessforcats
9,208 Expert Mod 8TB
C++ does not support default-int. You have to actually specify the type or say void.
Nov 26 '09 #2
tvnaidu
365 100+
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
newb16
687 512MB
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
tvnaidu
365 100+
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
9,208 Expert Mod 8TB
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
tvnaidu
365 100+
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
9,065 Expert Mod 8TB
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
tvnaidu
365 100+
thank you sir, let me reduce the size and make it minimum and compile.
Nov 29 '09 #9
tvnaidu
365 100+
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
9,208 Expert Mod 8TB
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.

Similar topics

2 posts views Thread by Henrik S. Hansen | last post: by
5 posts views Thread by j0mbolar | last post: by
4 posts views Thread by Juhan Voolaid | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.