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


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: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s


Thru Lens


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

%d bloggers like this: