discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pthread compilation problems


From: Robert Peterson
Subject: pthread compilation problems
Date: Tue, 15 Sep 2015 11:57:17 -0600

cross-post from: http://stackoverflow.com/questions/32555122/iso-c-forbids-declaration-of-pthread-cond-t-with-no-type

I'm getting some errors while trying to compile objective-c code that I didn't originally write. The platform is GNUstep on Windows 10. I'm very new to all this, so I suspect I'm making an elementary mistake.

Help!

Compilation Errors:

$ 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]