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
10 4310
C++ does not support default-int. You have to actually specify the type or say void.
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;
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
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?.
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.
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
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.
thank you sir, let me reduce the size and make it minimum and compile.
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
Maybe you could post your code for the functoin that contains line 564?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Henrik S. Hansen |
last post by:
I'm new to C++, and cannot figure out why this won't compile:
std::map<std::string, int> tst;
tst = 1;
int main() { /*...*/ }
It gives me:
error: ISO C++ forbids declaration of `tst' with...
|
by: j0mbolar |
last post by:
operator = (const char *string) {
if(m_string) {
free(m_string);
m_string = 0;
}
if(string) {
m_string = strdup(string);
}
}
|
by: Juhan Voolaid |
last post by:
Hi
I need help here. When i compile my program, i get this error:
$ make
g++ -c -Wall inf2_functions.cpp -o inf2_functions.o
inf2_classes.h:6: error: ISO C++ forbids declaration of ‘vector’...
|
by: gamehack |
last post by:
Hi all,
Here's the error which I'm getting when trying to compile some code:
boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:16: error: expected...
|
by: eric |
last post by:
hello
i'm trying to implement some functionality whereby an algorithm in a
base template class relies on a function pointer supplied by a derived
template class. the types are only specified by...
|
by: Florian Haag |
last post by:
Hello,
I'm trying to compile a programme which compiles fine under Linux; I'm
trying it with MinGW G++ 3.4.2:
Component.h:
#ifndef COMPONENT_H_
#define COMPONENT_H_
|
by: mkborregaard |
last post by:
Hi,
I am getting an error message from MinGW that I just cannot figure what causes.
The error message is:
"Line 16: ISO C++ forbids declaration of 'AreaMap' with no type"
My code is:
#ifndef...
|
by: aneuryzma |
last post by:
Hello,
I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using
xCode.
When I add #include "openCVApp.h"
I got the following error:
|
by: samsneelam |
last post by:
Hi..
This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob..
I am having two files .. one is mpcplib.h it contains the follwing...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |