Skip to content

Missing import statement in UnboundedBlockingQueue.h #1

Description

@theoknock

Trying to compile the above-referenced file results in a slew of errors, most of them like this:

~/Desktop/ThreadSampleCode/ThreadSampleCode/UnboundedBlockingQueue.m:17:9: Implicit declaration of function 'pthread_mutex_init' is invalid in C99

~/Desktop/ThreadSampleCode/ThreadSampleCode/UnboundedBlockingQueue.m:17:9: Declaration of 'pthread_mutex_init' must be imported from module 'Darwin.POSIX.pthread' before it is required

To fix it, add the following import statement to UnboundedBlockingQueue.h:

#import <pthread.h>

The new header file should now read, in totality:

#import <Foundation/Foundation.h>
#import <pthread.h>
#import <sys/time.h>
#import "Node.h"

@interface UnboundedBlockingQueue : NSObject{
@private
    pthread_mutex_t lock;
    pthread_cond_t notEmpty;
    Node *first, *last;
}

- (UnboundedBlockingQueue*) init;
- (void) put: (id) data;
- (id) take: (int) timeout;

@end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions