У меня есть ошибка, указывающая на линию Extred C при компиляции с C ++ 17 (Debian 12), но тот же код хорошо сочетается с C ++ 11 (Linux Mint). Есть идеи, почему? Невозможно получить никакой помощи от поставщика. < /P> #ifndef CONDITION_DEF_H
#define CONDITION_DEF_H
/* Condition_def.h; Class definition of class Thread.
*
* Copyright (c) 2000-2004 by Michael Weitzel.
* All rights reserved.
*/
#define SPURIOUS_WAKEUP_SAFE
//#define SPURIOUS_WAKEUP_UNSAFE
extern "C"
{
#include
}
#include "ThreadException.h"
namespace ThreadsPP
{
class Mutex;
/**
* Condition variables.
* The implementation offers the three classical operations
* wait(), signal() and broadcast().
*
* @author Michael Weitzel
* @brief A class implementing condition variables.
* @class Condition Condition.h
*/
class Condition
{
private:
/** pthread condition variable */
pthread_cond_t * pcond_;
/**
* flag; set to true iff the Condition object owns the
* pcond_ (not only shares it)
*/
bool pcowner_;
/**
* A eventually pending exception thrown during
* initialization.
*/
ThreadException * pending_exception_;
public:
/**
* The signal operation.
* Signals (reawakes) the next thread waiting on the
* condition variable.
*/
#if __cplusplus >= 201703L
inline void signal() throw ();
#else
inline void signal() throw (ThreadException);
#endif
/**
* The broadcast operation.
* Signals (reawakes) all threads waiting on the condition variable.
*/
#if __cplusplus >= 201703L
inline void broadcast() throw ();
#else
inline void broadcast() throw (ThreadException);
#endif
#ifdef SPURIOUS_WAKEUP_UNSAFE
/**
* The wait operation.
* Suspends a calling thread and unlocks a Mutex object to open
* a critical section.
*
* @param mutex Mutex object
*/
#if __cplusplus >= 201703L
inline void wait(Mutex & mutex) throw ();
#else
inline void wait(Mutex & mutex) throw (ThreadException);
#endif
/**
* The wait operation with timeout.
* Suspends a calling thread up to a specified timeout and unlocks a
* Mutex object.
*
* @param mutex Mutex object
* @param sec number of seconds for timeout
* @param usec number of microseconds for timeout
*/
#if __cplusplus >= 201703L
#else
inline bool timedwait(Mutex & mutex, long sec, long usec)
throw (ThreadException);
#endif
#endif
#ifdef SPURIOUS_WAKEUP_SAFE
/**
* The wait operation.
* Suspends a calling thread and unlocks a Mutex object to open
* a critical section.
*
* @param mutex Mutex object
*/
#if __cplusplus >= 201703L
inline void wait(Mutex & mutex, bool & predicate) throw ();
#else
inline void wait(Mutex & mutex, bool & predicate) throw (ThreadException);
#endif
/**
* The wait operation with timeout.
* Suspends a calling thread up to a specified timeout and unlocks a
* Mutex object.
*
* @param mutex Mutex object
* @param sec number of seconds for timeout
* @param usec number of microseconds for timeout
*/
#if __cplusplus >= 201703L
inline bool timedwait(Mutex & mutex, long sec, long usec, bool & predicate)
throw ();
#else
inline bool timedwait(Mutex & mutex, long sec, long usec, bool & predicate)
throw (ThreadException);
#endif
#endif
public:
/**
* Copy Constructor.
* Attaches the new Condition object to an existing object.
*
* @param copy existing condition object
*/
inline Condition(Condition const & copy)
: pcond_(copy.pcond_), pcowner_(false) {}
/**
* Constructor.
*/
inline Condition();
/**
* Destructor.
*/
inline ~Condition();
}; // class ThreadsPP::Condition
} // namespace ThreadsPP
#endif
< /code>
Я попытался Google и найти разрешение. Я попытался добавить такой #ifdef, но не решил. < /P>
#ifdef __cplusplus
extern "C"
{
#include
}
#endif
Подробнее здесь: https://stackoverflow.com/questions/794 ... -pthread-h
Ожидаемый инициализатор перед внешней частью, включив Pthread.h ⇐ Linux
-
Anonymous
1741561069
Anonymous
У меня есть ошибка, указывающая на линию Extred C при компиляции с C ++ 17 (Debian 12), но тот же код хорошо сочетается с C ++ 11 (Linux Mint). Есть идеи, почему? Невозможно получить никакой помощи от поставщика. < /P> [b]#ifndef CONDITION_DEF_H
#define CONDITION_DEF_H
/* Condition_def.h; Class definition of class Thread.
*
* Copyright (c) 2000-2004 by Michael Weitzel.
* All rights reserved.
*/
#define SPURIOUS_WAKEUP_SAFE
//#define SPURIOUS_WAKEUP_UNSAFE
extern "C"
{
#include
}
#include "ThreadException.h"
namespace ThreadsPP
{
class Mutex;
/**
* Condition variables.
* The implementation offers the three classical operations
* wait(), signal() and broadcast().
*
* @author Michael Weitzel
* @brief A class implementing condition variables.
* @class Condition Condition.h
*/
class Condition
{
private:
/** pthread condition variable */
pthread_cond_t * pcond_;
/**
* flag; set to true iff the Condition object owns the
* pcond_ (not only shares it)
*/
bool pcowner_;
/**
* A eventually pending exception thrown during
* initialization.
*/
ThreadException * pending_exception_;
public:
/**
* The signal operation.
* Signals (reawakes) the next thread waiting on the
* condition variable.
*/
#if __cplusplus >= 201703L
inline void signal() throw ();
#else
inline void signal() throw (ThreadException);
#endif
/**
* The broadcast operation.
* Signals (reawakes) all threads waiting on the condition variable.
*/
#if __cplusplus >= 201703L
inline void broadcast() throw ();
#else
inline void broadcast() throw (ThreadException);
#endif
#ifdef SPURIOUS_WAKEUP_UNSAFE
/**
* The wait operation.
* Suspends a calling thread and unlocks a Mutex object to open
* a critical section.
*
* @param mutex Mutex object
*/
#if __cplusplus >= 201703L
inline void wait(Mutex & mutex) throw ();
#else
inline void wait(Mutex & mutex) throw (ThreadException);
#endif
/**
* The wait operation with timeout.
* Suspends a calling thread up to a specified timeout and unlocks a
* Mutex object.
*
* @param mutex Mutex object
* @param sec number of seconds for timeout
* @param usec number of microseconds for timeout
*/
#if __cplusplus >= 201703L
#else
inline bool timedwait(Mutex & mutex, long sec, long usec)
throw (ThreadException);
#endif
#endif
#ifdef SPURIOUS_WAKEUP_SAFE
/**
* The wait operation.
* Suspends a calling thread and unlocks a Mutex object to open
* a critical section.
*
* @param mutex Mutex object
*/
#if __cplusplus >= 201703L
inline void wait(Mutex & mutex, bool & predicate) throw ();
#else
inline void wait(Mutex & mutex, bool & predicate) throw (ThreadException);
#endif
/**
* The wait operation with timeout.
* Suspends a calling thread up to a specified timeout and unlocks a
* Mutex object.
*
* @param mutex Mutex object
* @param sec number of seconds for timeout
* @param usec number of microseconds for timeout
*/
#if __cplusplus >= 201703L
inline bool timedwait(Mutex & mutex, long sec, long usec, bool & predicate)
throw ();
#else
inline bool timedwait(Mutex & mutex, long sec, long usec, bool & predicate)
throw (ThreadException);
#endif
#endif
public:
/**
* Copy Constructor.
* Attaches[/b] the new Condition object to an existing object.
*
* @param copy existing condition object
*/
inline Condition(Condition const & copy)
: pcond_(copy.pcond_), pcowner_(false) {}
/**
* Constructor.
*/
inline Condition();
/**
* Destructor.
*/
inline ~Condition();
}; // class ThreadsPP::Condition
} // namespace ThreadsPP
#endif
< /code>
Я попытался Google и найти разрешение. Я попытался добавить такой #ifdef, но не решил. < /P>
#ifdef __cplusplus
extern "C"
{
#include
}
#endif
Подробнее здесь: [url]https://stackoverflow.com/questions/79496733/expected-initializer-before-extern-when-including-pthread-h[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия