• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C language dialect and optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C language dialect and optimization


  • Subject: Re: C language dialect and optimization
  • From: Cem Karan <email@hidden>
  • Date: Wed, 27 Dec 2006 11:33:33 -0500

As I understand it, the line in gcc w/ c99 on:

   char* __restrict foo;

should be equivalent to the line in CW:

   char* restrict foo;

Is this correct?  I ask this because in one of my master headers,
I basically have:

#if __GNUC__
	#define restrict __restrict
#endif

In other words, anyone know why when c99 is enabled in gcc why
usage of 'restrict' emits errors.

In C99 mode IIRC it should understand restrict directly.


Hmmm... in C99 mode, the following emits an error in gcc (but no error in CW9):

void foo( char* restrict inPtr ) {
    ...
}

I'm guessing CW9 is forgiving on a compliance issue?  Otherwise, how
does one communicate to the compiler for a ptr argument to be
'restrict'?  I take it the answer is the unsightly approach:

void foo( char* inPtr ) {
    char* restrict ptr2 = (char* restrict) inPtr;
    ...
}

Seems kind of annoying to do, no?

Thanks,
Andy

Are you sure that you've got C99 mode on? I just compiled and tested the following:


#include <stdio.h>

void foo (char * restrict inPtr)
{
        printf(inPtr);
}

int main(int argc, char *argv[])
{
        foo("hello world\n");
        return 0;
}

with gcc -Wall -Wextra -pedantic -std=c99

without any complaints on the restrict keyword.

Also, your #define may be causing failures because you're trying to redefine a keyword. Try commenting it out, and see what happens.

And I apologize, but I'm going to be on vacation until Jan 2, so I won't see any comments you make until then.

Thanks,
Cem Karan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Setting a watchpoint in Xcode for a Java program
  • Next by Date: Re: g++ 4.0.2 linking problem
  • Previous by thread: Re: C language dialect and optimization
  • Next by thread: converting from cmd line to bundled
  • Index(es):
    • Date
    • Thread