ObjFW  Check-in [4c598e07ad]

Overview
Comment:Don't depend on objc/objc.h for compiler checks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4c598e07adc864a64f49b40884f0cc67723a3a52968e6c4ef676688e8370b39a
User & Date: js on 2011-03-21 12:43:19
Other Links: manifest | tags
Context
2011-03-21
12:47
Check whether optional protocols are supported. check-in: 09a49963de user: js tags: trunk
12:43
Don't depend on objc/objc.h for compiler checks. check-in: 4c598e07ad user: js tags: trunk
2011-03-17
20:33
Use Sleep(0) instead of yield() on Win32. check-in: eb827e8f21 user: js tags: trunk
Changes

Modified configure.ac from [3023082e96] to [142ef9b094].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
	NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
])
AC_SUBST(NO_CONST_CFSTRINGS)

AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([
	#import <objc/objc.h>

	@protocol OFFastEnumeration
	- (int)countByEnumeratingWithState: (void*)state
				   objects: (id*)objects
				     count: (int)count;
	@end
], [
	id n = nil;
	for (id i in n);
], [
	AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
		[Compiler support for Fast Enumeration])
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([
	#import <objc/objc.h>

	@interface Foo
	{
		id bar;
	}

	@property (retain, nonatomic) id bar;
	@end
], [
	Foo *foo = nil;
	[foo setBar: nil];
	[foo bar];
], [
	AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
	AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)







<
<


|



|
|










<
<





|


|
|







28
29
30
31
32
33
34


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
])
AC_SUBST(NO_CONST_CFSTRINGS)

AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([


	@protocol OFFastEnumeration
	- (int)countByEnumeratingWithState: (void*)state
				   objects: (struct objc_object**)objects
				     count: (int)count;
	@end
], [
	struct objc_object *n = (struct objc_object*)0;
	for (struct objc_object *i in n);
], [
	AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
		[Compiler support for Fast Enumeration])
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([


	@interface Foo
	{
		id bar;
	}

	@property (retain, nonatomic) struct objc_object *bar;
	@end
], [
	Foo *foo = (struct objc_object*)0;
	[foo setBar: (struct objc_object*)0];
	[foo bar];
], [
	AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
	AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wcast-align -Wpointer-arith"
	OBJCFLAGS="$OBJCFLAGS -Werror"

	AC_MSG_CHECKING(whether gcc has bug objc/27438)
	AC_TRY_COMPILE([
		#import <objc/objc.h>

		@interface OFConstantString
		{
			Class isa;
			const char *string;
			unsigned long size;
		}
		@end

		void *_OFConstantStringClassReference;
	], [
		OFConstantString *test = @"";
		test++; /* Get rid of unused variable warning */
	], [
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT([yes, adding -Wno-unused-variable])
		OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable"
		AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable")
	])

	AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs)
	AC_TRY_COMPILE([
		#import <objc/objc.h>

		@interface OFObject
		{
			Class isa;
		}
		@end

		static struct {
			Class isa;
		} object;
	], [
		OFObject *test = (OFObject*)&object;
		test++; /* Get rid of unused variable warning */
	], [
		AC_MSG_RESULT(no)
	], [







<
<


|



















<
<







|







455
456
457
458
459
460
461


462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483


484
485
486
487
488
489
490
491
492
493
494
495
496
497
498

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wcast-align -Wpointer-arith"
	OBJCFLAGS="$OBJCFLAGS -Werror"

	AC_MSG_CHECKING(whether gcc has bug objc/27438)
	AC_TRY_COMPILE([


		@interface OFConstantString
		{
			struct objc_class *isa;
			const char *string;
			unsigned long size;
		}
		@end

		void *_OFConstantStringClassReference;
	], [
		OFConstantString *test = @"";
		test++; /* Get rid of unused variable warning */
	], [
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT([yes, adding -Wno-unused-variable])
		OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable"
		AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable")
	])

	AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs)
	AC_TRY_COMPILE([


		@interface OFObject
		{
			Class isa;
		}
		@end

		static struct {
			struct objc_class *isa;
		} object;
	], [
		OFObject *test = (OFObject*)&object;
		test++; /* Get rid of unused variable warning */
	], [
		AC_MSG_RESULT(no)
	], [