Skip to Content.
Sympa Menu

freetds - Re: [freetds] Problem with datetime from a MS SQL Server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Problem with datetime from a MS SQL Server
  • Date: Mon, 10 Feb 2003 21:18:13 -0500 (EST)

On Mon, 10 Feb 2003, Steve Langasek wrote:

> However, since the type of all the members is the same, I don't think the
> added protection against accidental name collisions justifies the
> portability hit. I think it's better to use #defines, like so:
>
> #define dateyear year
> #define datedmonth day
> #define datedyear dayofyear
>
> typedef struct dbdaterec
> {
> DBINT year;
> DBINT datemonth;
> DBINT month;
> DBINT day;
> DBINT dayofyear;
> [...]
> } DBDATEREC;
>
> using the more esoteric of the names for the member as the alias, to
> reduce the chance of colliding with app variable names.
>
> Failing that, it's always possible to double the structure. <shrug>

Problem is, what goes in the some fields is different, datemonth != month
so some doubling is a given. I dislike unqualified defines as does any
dblib programmer who has to include another library that defines the type
"BYTE". bad bad bad. By nature, they'd have to be globally visible.

The memory cost of doubling is pretty insignificant (nobody stores many
DBDATERECs that I can think of, they are pretty much throw away
structures), and the processing amounts to half dozen extra mov ops.
Anybody see downsides to this approach?







Archive powered by MHonArc 2.6.24.

Top of Page