about aliasing

This is a discussion on about aliasing within the C Programming forums, part of the General Programming Boards category; Any use of restrict keyword I have seen is done in function declaration. Does have any sense to declare a ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    145

    about aliasing

    Any use of restrict keyword I have seen is done in function declaration. Does have any sense to declare a global var with restrict keyword? (yes, I now, I must not use globals.....)

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Kempelen View Post
    Does have any sense to declare a global var with restrict keyword? (yes, I now, I must not use globals.....)
    Sure, why not? As long as you are aware "restrict" is part of C99.

    BTW, you can use global variables, the caveat is not to become dependent on them and to use them as little as possible by reserving them only for important, often accessed variables and situations where NOT doing so would hamper efficiency or comprehensibility. For example, some API's allow callbacks where the callback can only be passed a single variable. You can always create a struct to include more, but if each one of these structs is unique in the sense that it is always variable X + some other variable, and X is getting passed around between a lot of your functions this (or any) way, you you might reasonably consider making X global if the total code base is only a few thousand lines or so.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Typesafe, generalized aliasing
    By CodeMonkey in forum C++ Programming
    Replies: 15
    Last Post: 12-13-2008, 08:52 PM
  2. Anti aliasing
    By arjunajay in forum Windows Programming
    Replies: 7
    Last Post: 08-15-2006, 08:24 PM
  3. pointer aliasing
    By moi in forum C Programming
    Replies: 2
    Last Post: 02-21-2006, 10:08 AM
  4. anti aliasing
    By muttski in forum Game Programming
    Replies: 2
    Last Post: 03-16-2002, 05:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21