Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #107891

Re: Need help fixing a "previously defined" error

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Need help fixing a "previously defined" error
Date 2017-04-08 15:33 -0400
Organization A noiseless patient Spider
Message-ID <ocbdnr$g7i$1@dont-email.me> (permalink)
References <20170408-130720.9.0@Peabody.ssl.astraweb.com> <t31iec5ro3htegq46dbo6s5fh93q0jvht9@4ax.com> <20170408-180409.292.0@Peabody.ssl.astraweb.com>

Show all headers | View raw


On 04/08/2017 02:04 PM, Peabody wrote:
> Barry Schwarz says...
> 
>  > The above conditional compilation is LCC's way of
>  > acknowledging that everything in that block is an
>  > extension to the language as defined by the standard.
>  > If you need any of those extensions, then you do not
>  > define the macro __ANSI__ONLY__.  If you don't want the
>  > LCC extensions, then you do define that macro.
...
> Doesn't it also raise the question of whether just defining
> the macro might cause the program to behave differently even
> if it successfully compiles?

Yes. That macro has a well-defined meaning for LCC - in principle, it
might have a completely different meaning (or none at all) when using
any other compiler (though with this particular name, it's unlikely to
do something completely different). Therefore, don't #define the macro
unless you first check the LCC documentation to verify what it means.

In general, turning ON C compliance should not be something done in your
code. My experience with other compilers (I have none with LCC itself)
suggests that LCC might automatically #define __ANSI_ONLY__ if you
choose the right command line option, so you don't need to #define it
yourself. Read the documentation for LCC to find out. -ansi is a popular
name for an option that turns on ANSI conformance.

> ...  In other words, if TI had
> included the macro originally, would the code still work the
> way it does?

It's quite likely that TI used a compiler that either didn't pay any
attention to __ANSI_ONLY__, or which automatically pre-#defines it when
appropriate options are selected. Either way, explicitly #defining it
would probably not have had an affect on the compiler they were using.


> ... I guess I don't understand whether ANSIC__ONLY
> just limits the functions that can be called, or whether it
> changes behavior (like long vs int as you described).

The only way to be sure is to read the LCC documentation. It's not a
general feature of C, it's compiler-specific.

> Anyway, the idea is that by defining the macro, I can
> otherwise leave TI's code the way it is, and leave LCC's
> string.h the way it is, but eliminate the error.

That would work, but I recommend removing the spurious declaration
instead. If it isn't actually being used, removing it is harmless. If it
is being used, removing it is a quick and simple way of finding out
where it's being used - doing so will almost certainly trigger an error
message if it is, in fact, being used.

...
>  > The bottom line is merely getting a clean compile should
>  > be only the first step before attempting any
>  > modifications.  You also need to verify that the newly
>  > compiled program behaves reasonably similar to the
>  > original program.
> 
> The program does lots of different things, and I don't
> really have a way to test all of them because I don't have
> the chips they apply to.

You only need to test the parts you plan to use.

> ...  Actually, I don't even understand
> all of them.  So you're saying that I would have to find the
> same version of Visual C that was used originally, which I
> don't think I know unless it's in the exe somewhere, to be
> sure that it behaves the same.

That would help, if it's easy to arrange. If not, you'll just have to
try it and see whether it works as intended.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 08:07 -0500
  Re: Need help fixing a "previously defined" error James Kuyper <jameskuyper@verizon.net> - 2017-04-08 10:47 -0400
    Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 12:51 -0500
      Re: Need help fixing a "previously defined" error Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-08 20:03 +0100
      Re: Need help fixing a "previously defined" error Spiros Bousbouras <spibou@gmail.com> - 2017-04-08 19:06 +0000
      Re: Need help fixing a "previously defined" error James Kuyper <jameskuyper@verizon.net> - 2017-04-08 15:17 -0400
  Re: Need help fixing a "previously defined" error Spiros Bousbouras <spibou@gmail.com> - 2017-04-08 15:29 +0000
  Re: Need help fixing a "previously defined" error Barry Schwarz <schwarzb@dqel.com> - 2017-04-08 09:21 -0700
    Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 13:04 -0500
      Re: Need help fixing a "previously defined" error James Kuyper <jameskuyper@verizon.net> - 2017-04-08 15:33 -0400
        Re: Need help fixing a "previously defined" error Spiros Bousbouras <spibou@gmail.com> - 2017-04-08 19:51 +0000
        Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 16:24 -0500
    Re: Need help fixing a "previously defined" error Keith Thompson <kst-u@mib.org> - 2017-04-08 18:45 -0700
  Re: Need help fixing a "previously defined" error bartc <bc@freeuk.com> - 2017-04-08 17:46 +0100
    Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 13:19 -0500
  Re: Need help fixing a "previously defined" error David Brown <david.brown@hesbynett.no> - 2017-04-09 12:38 +0200
    Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-09 07:52 -0500
      Re: Need help fixing a "previously defined" error David Brown <david.brown@hesbynett.no> - 2017-04-09 17:02 +0200
        Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-09 18:20 -0500
          Re: Need help fixing a "previously defined" error James Kuyper <jameskuyper@verizon.net> - 2017-04-09 22:06 -0400
          Re: Need help fixing a "previously defined" error David Brown <david.brown@hesbynett.no> - 2017-04-10 09:07 +0200
            Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-10 09:11 -0500
              Re: Need help fixing a "previously defined" error David Brown <david.brown@hesbynett.no> - 2017-04-10 17:31 +0200
                Re: Need help fixing a "previously defined" error Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-10 12:48 -0500

csiph-web