[freetds] FreeTDS Digest, Vol 44, Issue 4

entropy at freetds.org entropy at freetds.org
Mon Sep 4 13:25:09 EDT 2006

Norbert Sendetzky wrote:
> On Monday 04 September 2006 18:00, freetds-request at lists.ibiblio.org wrote:
>> The problem is that your code is making assumptions about what type a
>> CS_INT is.  If it were reasonable for your code to do that, then there
>> would be no such thing as a CS_INT, and instead it would just be "int"
>> or "long".
>> The most portable thing your code can do in this case is explicitly cast
>> to a type, then use the printf(3) format for that type.
>> CS_INT foo;
>> ...
>> printf("%ld\n", (long) foo);
>> That should compile without warnings and execute properly, using FreeTDS
>> or Sybase headers, on any 32 or 64 bit platform.
> It's not that I want to make assumptions about types but printf forces me to 
> do so. Your example above works as long as it doesn't hit a plattform 
> where "long" is defined as 64 bit type (e.g. Alpha, AIX). On these 
> plattforms, it will fail miserably.

Err, no, it works just fine on Alpha where I just tested it, and I see 
no reason why it shouldn't work on any other platform with 64-bit longs. 
  Can you explain why you think it should "fail miserably?"  If so, 
perhaps I can help you see where you're going wrong.

> On the other hand I don't know if there is a way out of this problem when two 
> libraries define CS_INT different. For the moment people using the sybase 
> backend in combination with FreeTDS have to live with this warnings.

Script started on Mon Sep  4 13:17:54 2006
sh-2.05b$ cat cs_int.c
#include <stdio.h>
#include <stdlib.h>
#include <cstypes.h>

main(int argc, char *argv[])
     CS_INT foo;

     foo = (CS_INT) 37;
     printf("%ld\n", (long) foo);
sh-2.05b$ gcc -Wall -I/sybase/OCS/include -o cs_int cs_int.c
sh-2.05b$ ./cs_int
sh-2.05b$ gcc -Wall -I/usr/local/include -o cs_int cs_int.c
sh-2.05b$ ./cs_int
sh-2.05b$ uname -a
OSF1 hostname V4.0 1530 alpha
sh-2.05b$ exit

script done on Mon Sep  4 13:19:38 2006


More information about the FreeTDS mailing list