Computer Chess Club Archives


Search

Terms

Messages

Subject: Using inline in GCC

Author: Omid David Tabibi

Date: 23:22:26 07/24/04

Go up one level in this thread


On July 24, 2004 at 19:05:45, Dieter Buerssner wrote:

>On July 24, 2004 at 18:45:28, Omid David Tabibi wrote:
>
>>#if defined (_MSC_VER)
>>#  define _LL(n)		(n ## I64)
>>#  define _ULL(n)		(n ## UI64)
>>#else
>>#  define _LL(n)		(n ## LL)
>>#  define _ULL(n)		(n ## ULL)
>>#endif
>>
>>So, in the above example I will do:
>>
>>if (variable == _ULL(0x123456789abcdef))
>
>Yes, this is a nice method. Unfortunately, it is not all, that is needed. You
>will need some other tricks for printf formats, too. Until now, it is still not
>so straightforward, to use 64-bit types in portable code.
>
>Why the leading underscore? Names starting with an underscore and an upper case
>letter are not free to use for (portable) user code. They are reserved for the
>compiler. I see often those leading underscores, I always wondered why?

No special reason. Well, I removed the underscore now :)

>
>Will MSVC need the UI64 or will it only warn, too?

In MSVC the problem is worse: if you don't mention UI64 it will do some stupid
things, and it won't even warn!

For example:

UINT64 num = 9837343779575477641;

num is not equal to 9837343779575477641, as the latter is treated a 32 bit
number, if not specified otherwise.

Or:

UINT64 num = 1 << 60;

num contains 0, because the number 1 is considered 32 bit, and so the whole
expression is calculated as 32 bit. The correct form would be:

UINT64 num = ULL(1) << 60;


Speaking of GCC, I have a problem porting my inline functions right now:

Assume I have the following function:

inline void SomeFunction() {
   ...
}

This function is accessed from several files. I mention that function in a
protos.h file, which is included in every cpp file:

extern void SomeFunction();

While this works fine in MSVC, GCC doesn't accept it. It seems that it doesn't
accept accessing of an inline function from another file. Any solution?





>For Gcc (or other compilers,
>that implement (unsigned) long long according to the C Standard), it is not
>needed. In general, I prefer to live with some harmless warnings, instead of
>writing code, that only is there, to avoid warnings.
>
>Regards,
>Dieter



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.