Skip to content

Missing import statement in UnboundedBlockingQueue.h #1

@theoknock

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

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