|
|
Choosing A Webhost: |
Re: code review?: msg#00036lang.perl.pdl.devel
----- 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> |
|---|---|---|
| Previous by Date: | Re: code review?, Bill Coffman |
|---|---|
| Next by Date: | Re: code review?, Bill Coffman |
| Previous by Thread: | Re: code review?, Bill Coffman |
| Next by Thread: | Re: code review?, Bill Coffman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |