logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: code review?: msg#00036

lang.perl.pdl.devel

Subject: Re: code review?


----- Original Message -----
From: "Bill Coffman"
.
.
> Anyway, here's the other thing to try (please correct
> any errors as I am programming to email):
>
> #include <stdio.h>
>
> union _pdl_nan_bits_float {unsigned char c[4]; float f;}
> union _pdl_nan_bits_double {unsigned char c[8]; double d;}
>
>
> #define NaN_float (((union _pdl_nan_bits_float) \
> {{0x7f, 0xff, 0xff, 0x7f}}) . f)
> #define NaN_double (((union _pdl_nan_bits_double) \
> {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}) . d)
>
> int main() {
>
> if(NaN_float != NaN_float) printf("ok1\n");
> if(NaN_double != NaN_double) printf("ok2\n");
>
> return 0;
> }
>

The only error I fixed was to add the missing semi-colon at the end of the 2
'union ..' declarations. It then works fine with gcc, but with Visual
Studio, it still won't compile:

-----------------------------------------------
F:\C>cat try.c
union _pdl_nan_bits_float {unsigned char c[4]; float f;};
union _pdl_nan_bits_double {unsigned char c[8]; double d;};


#define NaN_float (((union _pdl_nan_bits_float) \
{{0x7f, 0xff, 0xff, 0x7f}}) . f)
#define NaN_double (((union _pdl_nan_bits_double) \
{{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}) . d)

int main() {

if(NaN_float != NaN_float) printf("ok1\n");
if(NaN_double != NaN_double) printf("ok2\n");

return 0;
}
F:\C>cl try.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.

try.c
try.c(12) : error C2059: syntax error : '{'
try.c(13) : error C2059: syntax error : '{'
-----------------------------------------------------

Is there any reason we ought not make the following change to pdlcore.h.PL:

#ifdef _MSC_VER
#include <math.h>
#define NaN_float ((float)sqrt(-1))
#define NaN_double ((double)sqrt(-1))
#else
#define NaN_float (((union {unsigned char c[4]; float d;}) \
{{0x7f, 0xff, 0xff, 0x7f}}) . d)
#define NaN_double (((union {unsigned char c[8]; double d;}) \
{{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}) . d)
#endif

(Actually, I'm not sure that it's necessary to '#include <math.h>'.)

When I make that change in pdlcore.h.PL, I find that PDL builds and tests
fine with Visual Studio.

Cheers,
Rob


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
krysalis.sandbo...    web.zope.zwiki/...    gnome.apps.gnum...    xfree86.newbie/...    editors.vim/200...    mozilla.enigmai...    boot-loaders.gr...    network.vnc.ult...    redhat.release....    java.geronimo.u...    os.netbsd.devel...    horde.wicked/20...    linux.lsb.discu...    ietf.ips/2005-0...    alsa.devel/2002...    user-groups.lin...    package-managem...    debian.devel.da...    security.cyrus....    video.gstreamer...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation