[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to enable "shorthand" access element in NSArray
From: |
Rael Bauer |
Subject: |
Re: How to enable "shorthand" access element in NSArray |
Date: |
Sun, 28 Dec 2014 21:59:16 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 |
On 2014/12/28 12:47 PM, David Chisnall wrote:
Are you targeting the non-fragile ABI?
I was not aware of whether I was or wasn't (I am very new to
gnustep/objective-C). After some research it seems that I was not. (just
using the default). If I add this line to the GNUmakefile:
test_OBJCFLAGS += -fobjc-nonfragile-abi
Then it does compile ok (there is a warning though), however then the
linker gives a list of errors
./obj/test.obj/test.m.o: In function `main':
C:/GNUstep/msys/1.0/home/User/Projects/Test/test.m:7: undefined
reference to `objc_msgSend'
C:/GNUstep/msys/1.0/home/User/Projects/Test/test.m:8: undefined
reference to `objc_msgSend'
C:/GNUstep/msys/1.0/home/User/Projects/Test/test.m:13: undefined
reference to `objc_msgSend'
C:/GNUstep/msys/1.0/home/User/Projects/Test/test.m:15: undefined
reference to `objc_msgSend'
collect2: ld returned 1 exit status
Do you have any advice on how to fix this error?
This array accessor notation is a terrible idea,
Can you please elaborate on why you say that?
so I'd recommend that you avoid it,
I am going through a tutorial/lecture series, which is based on XCode,
and trying to follow the code on Windows with GNUstep. It makes it a lot
easier if I can just use the code provided by the lecture instead of
making changes to every few lines..
as it (along with the property notation) destroy one of the key strengths of
Objective-C: the orthogonality of syntax. In particular, with the fragile ABI, you
were allowed to allocate C arrays of objects, so myArray[1] means *(&myArray +
1). It looks like that's what you're getting here, because the result of this will
be an NSArray (not an NSArray*), which is incompatible with an id.
And are you sure that you're using clang? That looks very much like a GCC
error...
Yes, I do think so. I have
CC=clang in the GNUmakefile, (clang version 3.4)
This line: NSArray * myArray = @[@"A", @"B", @"C"];
does not compile without it.
Thanks
-Rael