Compiling C programs in VS.NET 2005
-
I have a C program, which has to be compiled in VS.NET 2005 environment. I don't have any issues with the compilation part and the EXE is generated. When I run the EXE the program is looping. Pls find below the source code: /* ------------------------------------------------------------------------ */ /* Program Name : GLDBACK2.C */ /* Last Modified : 03/11/08 - RMC - Creation date */ /* N.B. GLD0DETL has 190 fields and is 1287 bytes */ /* */ /* ------------------------------------------------------------------------ */ /************************************************************************** */ /* Reads dBase file and outputs as text file. */ /* Based on Valour Software freeware. */ /************************************************************************** */ #include <fcntl.h> #include <sys\types.h> #include <sys\stat.h> #include <io.h> #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct dbase_head { unsigned char version; /*03 for dbIII and 83 for dbIII w/memo file*/ unsigned char l_update[3]; /*yymmdd for last update*/ unsigned long count; /*number of records in file*/ unsigned int header; /*length of the header *includes the \r at end */ unsigned int lrecl; /*length of a record *includes the delete *byte */ unsigned char reserv[20]; } DBASE_HEAD; typedef struct dbase_fld { char name[11]; /*field name*/ char type; /*field type*/ #define DB_FLD_CHAR 'C' #define DB_FLD_NUM 'N' #define DB_FLD_LOGIC 'L' #define DB_FLD_MEMO 'M' #define DB_FLD_DATE 'D' /* A-T uses large data model but drop it for now */ //char far *data_ptr; /*pointer into buffer*/ unsigned char length;
-
I have a C program, which has to be compiled in VS.NET 2005 environment. I don't have any issues with the compilation part and the EXE is generated. When I run the EXE the program is looping. Pls find below the source code: /* ------------------------------------------------------------------------ */ /* Program Name : GLDBACK2.C */ /* Last Modified : 03/11/08 - RMC - Creation date */ /* N.B. GLD0DETL has 190 fields and is 1287 bytes */ /* */ /* ------------------------------------------------------------------------ */ /************************************************************************** */ /* Reads dBase file and outputs as text file. */ /* Based on Valour Software freeware. */ /************************************************************************** */ #include <fcntl.h> #include <sys\types.h> #include <sys\stat.h> #include <io.h> #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct dbase_head { unsigned char version; /*03 for dbIII and 83 for dbIII w/memo file*/ unsigned char l_update[3]; /*yymmdd for last update*/ unsigned long count; /*number of records in file*/ unsigned int header; /*length of the header *includes the \r at end */ unsigned int lrecl; /*length of a record *includes the delete *byte */ unsigned char reserv[20]; } DBASE_HEAD; typedef struct dbase_fld { char name[11]; /*field name*/ char type; /*field type*/ #define DB_FLD_CHAR 'C' #define DB_FLD_NUM 'N' #define DB_FLD_LOGIC 'L' #define DB_FLD_MEMO 'M' #define DB_FLD_DATE 'D' /* A-T uses large data model but drop it for now */ //char far *data_ptr; /*pointer into buffer*/ unsigned char length;
Some suggestions: - Please use the pre tag to format your code properly. As it is now, it is barely readable. - What do you mean by "it loops" exactly ? Is it hanging ? - Did you try to use your debugger to track down the problem ?
Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++ -
I have a C program, which has to be compiled in VS.NET 2005 environment. I don't have any issues with the compilation part and the EXE is generated. When I run the EXE the program is looping. Pls find below the source code: /* ------------------------------------------------------------------------ */ /* Program Name : GLDBACK2.C */ /* Last Modified : 03/11/08 - RMC - Creation date */ /* N.B. GLD0DETL has 190 fields and is 1287 bytes */ /* */ /* ------------------------------------------------------------------------ */ /************************************************************************** */ /* Reads dBase file and outputs as text file. */ /* Based on Valour Software freeware. */ /************************************************************************** */ #include <fcntl.h> #include <sys\types.h> #include <sys\stat.h> #include <io.h> #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct dbase_head { unsigned char version; /*03 for dbIII and 83 for dbIII w/memo file*/ unsigned char l_update[3]; /*yymmdd for last update*/ unsigned long count; /*number of records in file*/ unsigned int header; /*length of the header *includes the \r at end */ unsigned int lrecl; /*length of a record *includes the delete *byte */ unsigned char reserv[20]; } DBASE_HEAD; typedef struct dbase_fld { char name[11]; /*field name*/ char type; /*field type*/ #define DB_FLD_CHAR 'C' #define DB_FLD_NUM 'N' #define DB_FLD_LOGIC 'L' #define DB_FLD_MEMO 'M' #define DB_FLD_DATE 'D' /* A-T uses large data model but drop it for now */ //char far *data_ptr; /*pointer into buffer*/ unsigned char length;
-
Did it compile on the platform you've been porting it from? If it didn't it might be worth debugging it there rather than using a tool you're unfamiliar with. Cheers, Ash
I am familiar only with VS.NET environment. I was able to debug and found that dbhead.lrecl property is showing "0". Also I don't have MC6 environment. But I am not able to guess why record length property (dbread.lrecl) is giving "0". If this has some value, then my EXE will work. Any ideas?
-
I am familiar only with VS.NET environment. I was able to debug and found that dbhead.lrecl property is showing "0". Also I don't have MC6 environment. But I am not able to guess why record length property (dbread.lrecl) is giving "0". If this has some value, then my EXE will work. Any ideas?
-
I'd look in db3_read_dic myself, that seems to be where the header's read. Start there and work out. Cheers, Ash
It is a VC++, Win32 project created in VS.NET 2005 environment. I knew where the header is being read. But the property dbhead.lrecl itself is giving a value of 0. It is just a straight forward property...
-
It is a VC++, Win32 project created in VS.NET 2005 environment. I knew where the header is being read. But the property dbhead.lrecl itself is giving a value of 0. It is just a straight forward property...
Okay, so you know something's going wrong with the read. Next step is to find out what! I can't answer this as I don't have (or want) access to your data file. So have you checked... - that the data's kosher - what you really think's in the file is in the file - that the compiler's not making some assumptions about the size of data objects? That code looks so old it might be a 16 bit relic or the compiler may have made different assumptions about structure packing and so on... Cheers, Ash