2015-09-13 7 views
1

У меня возникают некоторые ошибки при попытке скомпилировать объектный код, который я изначально не написал. Платформа GNUstep в Windows 10. Я очень новичок во всем этом, поэтому я подозреваю, что делаю элементарную ошибку.ISO C++ запрещает объявление 'pthread_cond_t' без типа

Помощь!

компиляции Ошибки:

$ make 
This is gnustep-make 2.6.5. Type 'make print-gnustep-make-help' for help. 
Making all for tool stockfish... 
Compiling file main.m ... 
Compiling file EngineController.mm ... 
In file included from EngineController.mm:1:0: 
EngineController.h:6:4: error: ISO C++ forbids declaration of 'pthread_cond_t' with no type [-fpermissive] 
EngineController.h:6:19: error: expected ';' before 'WaitCondition' 
EngineController.h:7:4: error: ISO C++ forbids declaration of 'pthread_mutex_t' with no type [-fpermissive] 
EngineController.h:7:20: error: expected ';' before 'WaitConditionLock' 
EngineController.mm: In function '-[EngineController initEngine]': 
EngineController.mm:10:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 
EngineController.mm:13:27: error: 'WaitConditionLock' was not declared in this scope 
EngineController.mm:13:50: error: 'pthread_mutex_init' was not declared in this scope 
EngineController.mm:14:26: error: 'WaitCondition' was not declared in this scope 
EngineController.mm:14:45: error: 'pthread_cond_init' was not declared in this scope 
EngineController.mm:18:12: warning: 'objc_object* objc_get_class(const char*)' is deprecated (declared at C:/GNUstep/GNUstep/System/Library/Headers/objc/runtime-deprecated.h:30) [-Wdeprecated-declarations] 
make[3]: *** [obj/stockfish.obj/EngineController.mm.o] Error 1 
make[2]: *** [internal-tool-all_] Error 2 
make[1]: *** [stockfish.all.tool.variables] Error 2 
make: *** [internal-all] Error 2 

GNUmakefile

include $(GNUSTEP_MAKEFILES)/common.make 

TOOL_NAME = stockfish 
stockfish_OBJC_FILES = main.m 
stockfish_OBJCC_FILES = EngineController.mm 

include $(GNUSTEP_MAKEFILES)/tool.make 

main.m

#import <Foundation/Foundation.h> 
#import <pthread.h> 
#import <EngineController.h> 

int 
main (void) 
{ 

    [[Controller alloc] init]; 

    return 0; 
} 

EngineController.h

#import <Foundation/Foundation.h> 

@class Controller; 

@interface EngineController : NSObject { 
    pthread_cond_t WaitCondition; 
    pthread_mutex_t WaitConditionLock; 
    BOOL ignoreBestmove; 
    BOOL engineThreadShouldStop; 
    BOOL engineThreadIsRunning; 
    BOOL engineIsThinking; 
} 

@property (nonatomic, readonly) BOOL engineIsThinking; 
@property (nonatomic, readonly) BOOL engineThreadIsRunning; 

- (void)initEngine; 

@end 

extern EngineController *GlobalEngineController; 

EngineController.mm

#import "EngineController.h" 

EngineController *GlobalEngineController; 

@implementation EngineController 

@synthesize engineIsThinking, engineThreadIsRunning; 

- (void)initEngine { 
    if (self = [super init]) { 

     // Initialize locks and conditions 
     pthread_mutex_init(&WaitConditionLock, NULL); 
     pthread_cond_init(&WaitCondition, NULL); 

     // Start engine thread 
     NSThread *thread = 
     [[NSThread alloc] initWithTarget: self 
           selector: @selector(startEngine:) 
            object: nil]; 
     [thread setStackSize: 0x100000]; 
     [thread start]; 
     [thread release]; 

     ignoreBestmove = NO; 
     engineIsThinking = NO; 
    } 
    GlobalEngineController = self; 
} 

@end 
+1

ну как программист на C++, как я могу вам сказать, это * «C++ запрещает объявление« pthread_cond_t »без сообщения типа« * », вероятно, вызвано не включением/импортом 'pthread.h', но я не уверен, как вы ожидаете этого в объективе c. Удачи! –

+0

Спасибо, я попытался сделать это с '#import ' в 'main.m' - возможно, это неверно – Lightbeard

ответ

0

discuss-gnustep список рассылки при условии, что решение: #import <pthread.h> был в неправильном месте. Это должно быть в EngineController.h вместо main.m