Static versus Extern

GCC 4.0 now warns if your project defines the same variables as extern and static. In the past the compiler used to respect which ever declarations it encountered last.

// foo.h

extern int _defaultWidth; // used by lots of compilation units

// foo.c

static int _defaultWidth; // local copy – ERROR : static declaration of ‘_defaultWidth’ follows non-static declaration

Advertisements

0 Responses to “Static versus Extern”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Pages

Thru Lens



More Photos

Tweets

View Karthikeyan S's profile on LinkedIn
Alltop, confirmation that we kick ass

%d bloggers like this: