C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-11-2009, 06:54 AM   #1
Registered User
 
Join Date: Feb 2008
Posts: 93
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.....)
Kempelen is offline   Reply With Quote
Old 11-11-2009, 08:39 AM   #2
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
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.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Typesafe, generalized aliasing CodeMonkey C++ Programming 15 12-13-2008 09:52 PM
Anti aliasing arjunajay Windows Programming 7 08-15-2006 08:24 PM
pointer aliasing moi C Programming 2 02-21-2006 11:08 AM
anti aliasing muttski Game Programming 2 03-16-2002 06:55 AM


All times are GMT -6. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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