SE_sql_construct_alloc returns invalid SE_SQL_CONSTRUCT struct from ArcSDK10.2 C API

3808
1
Jump to solution
01-15-2015 07:06 PM
New Contributor III


Hi all,

We have an application using ArcSDE SDK C API to translate our data to ArcGIS SDE geodatabase.

Our application runs OK with ArcSDE SDK 10.0 for years without problems.

When we re-build the same code using ArcSDE SDK 10.2 (64 bits),it is found that the structure allocated by

SE_sql_construct_alloc(1, &sqlc)  can not be used. The problem can be reproduced by the code below.

After further investigation,I have noticed that it is the complier option /Zp1 caused the invalid
structure returned.
The code below works ok if it is compiled with /Zp8 or /Zp16. It will crash if it is complied with  /Zp1.

This indicates ArcSDK SDE 10.2 requies 8 or 16 bytes as the Struct member Alignment, however in
our application we requires 1 byte as the Struct member Alignment.

Can anyone suggest how we solves the conflict?

We don’t have the problem with ArcSDE SDK 10.0.

Any help is much appreciated.

int main(int argc, char* argv[])

{

       long        rc;

       SE_SQL_CONSTRUCT    *sqlc;

       SE_CONNECTION connection;

      

      rc = SE_connection_create(NULL, "sde:sqlserver:sql_instance", "SDI", NULL, NULL, &error,&connection);   

         

      // Allocate an SE_SQL_CONSTRUCT 

      rc = SE_sql_construct_alloc(1, &sqlc);

      sqlc->num_tables = 1;

      //the code crahses at the below strcpy, debug shows sqlc->tables[0] invalid     

      strcpy(sqlc->tables[0],  "TEST");

      

      printf("table%s\n", sqlc->tables[0]);

      return 0;

}

Best regards,

Youmei

Reply
0 Kudos
1 Solution

Accepted Solutions
New Contributor III

I have worked out a solution:

1. Use  #pragma pack(1) and #pragma pack(8) at the different place of the code as needed.

2. Use /Zp8 as a complier option.

View solution in original post

Reply
0 Kudos
1 Reply
New Contributor III

I have worked out a solution:

1. Use  #pragma pack(1) and #pragma pack(8) at the different place of the code as needed.

2. Use /Zp8 as a complier option.

View solution in original post

Reply
0 Kudos