Pro*C and nomember_alignment precompiler option on DEC UNIX
Date: 1996/11/07
Message-ID: <01bbccc7$17023740$0302a8c0_at_marcos.trs.it>#1/1
Hi,
I need a help.
I now developing on a system with this configuration:
-Dec Alpha with DEC UNIX 3.2c;
-Oracle Server 7.2.2.4;
-Oracle Pro*C 2.1.2.0.
I need to use in C the precompiler directive #pragma nomember_alignment
for forcing byte-alignment.
But, if I use that directive, Oracle seems to fail in retrieving the
correct
16-bit value from the database.
The errors occours only when the target field (short int) of my structure
has a relative offset multiple of 64-bit
I attach the source code and output.
#pragma nomember_alignment /* this is the precompile directive */ #include <sqlca.h>
typedef struct { /* this is my structure */ unsigned char a[7]; unsigned short int b; unsigned char a1[6]; unsigned short int b1;
} T_sup_mes;
T_sup_mes sup_msg; unsigned short int appo_range;
main (int argc, char *argv[])
{
int i; char username[20],password[20];
strcpy(username, "smart");
strcpy(password, "smart");
EXEC SQL WHENEVER SQLERROR DO sql_error_ret("1) ORACLE error--\n");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nbefore...\n\n");
for (i=0; i<sizeof(T_sup_mes); i++){
printf("%d) %X\n", i, ((unsigned char *)(&sup_msg))[i]);
}
/* now retrive the correct value from the database */ EXEC SQL SELECT range_scale INTO :appo_range
FROM firw_conftab;
/* this select doesn't retreive the correct value */ EXEC SQL SELECT range_scale, range_scale
INTO :sup_msg.b, :sup_msg.b1 FROM firw_conftab;
printf("\n\n...after\n\n");
for (i=0; i<sizeof(T_sup_mes); i++){
printf("%d) %x\n", i, ((unsigned char *)(&sup_msg))[i]);
}
printf("\nthe correct value= %X\n\n", appo_range);
EXEC SQL COMMIT WORK RELEASE;
}
void sql_err_ret(char * msg)
{
printf("%s",msg);
}
The program output is ...
before...
0) 0 1) 0 2) 0 3) 0 4) 0 5) 0 6) 0 7) 0 8) 0 9) 0 10) 0 11) 0 12) 0 13) 0 14) 0 15) 0 16) 0 ........after 0) 0 1) 0 2) 0 3) 0 4) 0 5) 0 6) 0 7) c0 8) 0 9) 0 10) 0 11) 0 12) 0 13) 0 14) 0 15) c0 16) 0
the correct value= 11C0
Tanks.
-- Marco Sciarroni E-mail: Marco.Sciarroni_at_trs.it T.R.S. S.p.A. Via V. G. Galati, 91 Tel: ++39-(0)6-4063911 00155 ROMA Italy Fax: ++39-(0)6-4060300Received on Thu Nov 07 1996 - 00:00:00 CET