Re: SOLVED OT - C compiler, assignement on double-declared variable with different types

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Philip Guenther
Date: Sunday, April 11, 2010 - 12:41 am

On Sat, Apr 10, 2010 at 10:14 PM, Jesus Sanchez <zexel08@gmail.com> wrote:
...

It violates a constraint of the C standard for two translation units
of a program to have different tentative definitions for a single
(necessarily external) identifier.  Therefore, the behavior of your
program is NOT DEFINED BY THE C STANDARD.

If you're interested in the chapter-and-verse of this, I suggest you
take it to USENET, comp.lang.c



You were doing something that isn't guaranteed by the standard and
whose behavior isn't guaranteed by OpenBSD.  If you ever upgrade your
system or try to compile this software on other systems, it may behave
differently WITH NO WARNING.

Given that, writing such code seems...unwise.  I certainly recommend
against doing so.


...

<sigh>

1) alignment != allocated size.  A one byte variable might have 4 byte
alignment...and yet still share space with another variable with a
less strict alignment!

2) To steal a quote from Blair Houghton: "'I read it on a random web
site' that's sort of like hearsay evidence from Richard Nixon..."
You've quoted a website; do you have a *good* reason for believing
that their quote applies to (1) the software you're running, or (2)
the software you will be running in the future?



The only harm is to your reputation as a C programmer.  For example, I
would not hire a programmer who said "it's okay to have conflicting
variable definitions in different translation units".


Philip Guenther
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: SOLVED OT - C compiler, assignement on double-declared ..., patrick keshishian, (Sat Apr 10, 10:49 pm)
Re: SOLVED OT - C compiler, assignement on double-declared ..., patrick keshishian, (Sun Apr 11, 12:06 am)
Re: SOLVED OT - C compiler, assignement on double-declared ..., Philip Guenther, (Sun Apr 11, 12:41 am)
Re: OT - C compiler, assignement on double-declared variab ..., patrick keshishian, (Sun Apr 11, 12:27 pm)