Re: SC_IS_PRERELEASE and TLM_IS_PRERELEASE

From: <john.aynsley@doulos.com>
Date: Tue Jan 18 2011 - 04:59:24 PST

Philipp,

I would go with David and vote for a simple 0 or 1.

John A

From:
David C Black <dcblack@xtreme-eda.com>
To:
Philipp A. Hartmann <philipp.hartmann@offis.de>
Cc:
john.aynsley@doulos.com, systemc-p1666-technical@eda.org
Date:
18/01/2011 03:16
Subject:
Re: SC_IS_PRERELEASE and TLM_IS_PRERELEASE

The standard definitely says lowercase true/false are the correct values.
However,
there is another consideration, CPP, the C preprocessor. The GNU 4.0
manual states:

The preprocessor does not know anything about types in the language.
Therefore, sizeof operators are not recognized in ?#if?, and neither are
enum constants. They will be taken as identifiers which are not macros,
and replaced by zero. In the case of sizeof, this is likely to cause the
expression to be invalid.

The preprocessor calculates the value of expression. It carries out all
calculations in the widest integer type known to the compiler; on most
machines supported by GCC this is 64 bits. This is not the same rule as
the compiler uses to calculate the value of a constant expression, and may
give different results in some cases. If the value comes out to be nonzero
, the ?#if? succeeds and the controlled text is included; otherwise it is
skipped.

So I think we should use 1 and 0.

On Jan 17, 2011, at 5:31 PM, Philipp A. Hartmann wrote:

John,

I've checked this issue on MS Visual C++ as well. There, TRUE/FALSE are
defined (due to windows.h) and unfortunaly true/false are not supported
as constant expression (although they should, according to my
understanding of the C++ standard).

 A platform independent definition should then use 1/0, respectively.
Thus, the extended wording from my last mail seems to be the best way to
go. The implementer can then provide a suitable definition for all the
supported platforms.

Opinions?

Greetings from Oldenburg,
 Philipp

On 12/01/11 15:42, Philipp A. Hartmann wrote:
John,

On 12/01/11 15:13, john.aynsley@doulos.com wrote:

What precisely are you proposing we do instead?

For simplicity, I would propose to just spell 'false' and 'true' in
lower-case. These are valid constant expressions for the C(++)
preprocessor, evaluating to 0 and 1.

A more elaborate definition could use the following:

 The TLM_IS_PRERELEASE flag shall be a controlling constant expression
 (see ISO/IEC14882:2003, 16.1(4)), evaluating to 0 or 1, respectively.

Greetings from Oldenburg,
 Philipp

From:
"Philipp A. Hartmann" <philipp.hartmann@offis.de>
To:
john.aynsley@doulos.com
Cc:
systemc-p1666-technical@eda.org
Date:
12/01/2011 01:45
Subject:
Re: SC_IS_PRERELEASE and TLM_IS_PRERELEASE

John, all,

I've checked this again. TRUE and FALSE are neither part of the C nor
the C++ standard.

 They are defined by some platforms (e.g. on Windows), and also
commonly defined in C applications, but the latter mostly due to the
lack of proper bool support.

 Wrt. to backwards compatibility, I highly doubt that there are
frequent uses of this, since the current TLM-2 kit is just broken in
that regard. Try the following on a non-Windows platform:

// ---8<---
#include <systemc>
#include <tlm.h>

int sc_main( int, char*[] )
{
# if TLM_IS_PRERELEASE == TRUE
   std::cout << "TLM pre-release" << std::endl;
# endif

# if TLM_IS_PRERELEASE == FALSE
   std::cout << "TLM not a pre-release" << std::endl;
# endif
 return 0;
}
// --->8---

 This prints, _both_ lines on my default Linux/GCC 4.4 platform, since
TRUE and FALSE are undefined. And comparing two undefined symbols is
quite ? undefined. ;-)

Greetings from Oldenburg,
 Philipp

On 11/01/11 13:37, john.aynsley@doulos.com wrote:
All,

Philipp writes:

9.6.5 SystemC Version
11.8.1 TLM version information

 SC_IS_PRERELEASE
 TLM_IS_PRERELEASE

 "... flag shall be either FALSE or TRUE, not enclosed in quotation
marks."

 Hmmm, maybe 'true' or 'false' (lower-case) would be more portable?
 Or even an application-defined integral constant expression evaluating

to 0/1 (or false/true).

[JA] I guess FALSE and TRUE are still required for backward
compatibility
in the TLM-2.0 world?

-- 
Philipp A. Hartmann
Hardware/Software Design Methodology Group
OFFIS Institute for Information Technology
R&D Division Transportation · FuE-Bereich Verkehr
Escherweg 2 · 26121 Oldenburg · Germany · http://offis.de/en/
Phone/Fax: +49-441-9722-420/282 · PGP: 0x9161A5C0 · Skype: phi.har
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
------------------------------------------------------
David C Black, System-Level Specialist
XtremeEDA USA Corporation http://www.Xtreme-EDA.com
(Consulting, Services & Training for all your ESL design assurance needs)
Voice: 512.850.4322 Skype: dcblack FAX: 888.467.4609
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jan 18 05:00:15 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 18 2011 - 05:00:16 PST