NO

Author Topic: error while compiling  (Read 12434 times)

zenonpro

  • Guest
error while compiling
« on: May 03, 2005, 12:12:56 AM »
I'm currently testing Pelles C in order to make the transition from Codewarrior 6.1 (release 9, which I was about to purchase, seems to be the last version metrowerks will produce).  I must say I was pleasantly surprised to see the quality of the IDE.  My toolkit and access-modules compiled without significant modifications.  The first application however, I stumbled over a strange error, which I cannot resolve.  Maybe you can help me out

/**************************************************************************/
/* egcs-1.1.2                                                             */
/**************************************************************************/
/* FILE: AccRegister.h                                                    */
/**************************************************************************/
/* Developed by:           ZENON productions.                             */
/* Programmer:             Qgen v 1.0  release 42                         */
/* System:                 AMD XP2800+  2 x 80GB                          */
/* Language:               ANSI C                                         */
/* Date of beginning:      28/03/2005                                     */
/* Date of accomplishment:                                                */
/* Version:                1.0.42                                         */
/* Revision History:       None.                                          */
/*                                                                        */
/**************************************************************************/
#ifndef __ACCREGISTER
 #define __ACCREGISTER


#include "PgresTools.h"

/* Include acces module headers */
#include "AccArtikels.h"
#include "Acc.h"
#include "AccArtlev.h"
#include "AccArttypes.h"
#include "AccBesteldetail.h"
#include "AccBestellingen.h"
#include "AccCalendar.h"
#include "AccFieldctrl.h"
#include "AccFormcolumns.h"
#include "AccFormdivisions.h"
#include "AccFormkaders.h"
#include "AccFormobjects.h"
#include "AccFormoptions.h"
#include "AccFormulieren.h"
#include "AccFreesql.h"
#include "AccKaders.h"
#include "AccKadtypes.h"
#include "AccKlanten.h"
#include "AccKlantenkaart.h"
#include "AccLeveranciers.h"
#include "AccMenus.h"
#include "AccMerklev.h"
#include "AccOrderdetail.h"
#include "AccOrders.h"
#include "AccParms.h"
#include "AccPerlenum.h"
#include "AccPostcodes.h"
#include "AccPrijsgroepen.h"
#include "AccPrinters.h"
#include "AccRitscolo.h"
#include "AccStaffel.h"
#include "AccTappi.h"
#include "AccUsers.h"

/* Defines */
#define ACC_NMODULES      33


/* Global structure for registering tables */
static tsRegisterCtrl rRegister[]={{DbtRegisterArtikels,ARTIKELS_VERSION},
                                   {DbtRegisterArtlev,ARTLEV_VERSION},
                                   {DbtRegisterArttypes,ARTTYPES_VERSION},
                                   {DbtRegisterBesteldetail,BESTELDETAIL_VERSION},
                                   {DbtRegisterBestellingen,BESTELLINGEN_VERSION},
                                   {DbtRegisterCalendar,CALENDAR_VERSION},
                                   {DbtRegisterFieldctrl,FIELDCTRL_VERSION},
                                   {DbtRegisterFormcolumns,FORMCOLUMNS_VERSION},
                                   {DbtRegisterFormdivisions,FORMDIVISIONS_VERSION},
                                   {DbtRegisterFormkaders,FORMKADERS_VERSION},
                                   {DbtRegisterFormobjects,FORMOBJECTS_VERSION},
                                   {DbtRegisterFormoptions,FORMOPTIONS_VERSION},
                                   {DbtRegisterFormulieren,FORMULIEREN_VERSION},
                                   {DbtRegisterFreesql,FREESQL_VERSION},
                                   {DbtRegisterKaders,KADERS_VERSION},
                                   {DbtRegisterKadtypes,KADTYPES_VERSION},
                                   {DbtRegisterKlanten,KLANTEN_VERSION},
                                   {DbtRegisterKlantenkaart,KLANTENKAART_VERSION},
                                   {DbtRegisterLeveranciers,LEVERANCIERS_VERSION},
                                   {DbtRegisterMenus,MENUS_VERSION},
                                   {DbtRegisterMerklev,MERKLEV_VERSION},
                                   {DbtRegisterOrderdetail,ORDERDETAIL_VERSION},
                                   {DbtRegisterOrders,ORDERS_VERSION},
                                   {DbtRegisterParms,PARMS_VERSION},
                                   {DbtRegisterPerlenum,PERLENUM_VERSION},
                                   {DbtRegisterPostcodes,POSTCODES_VERSION},
                                   {DbtRegisterPrijsgroepen,PRIJSGROEPEN_VERSION},
                                   {DbtRegisterPrinters,PRINTERS_VERSION},
                                   {DbtRegisterRitscolo,RITSCOLO_VERSION},
                                   {DbtRegisterStaffel,STAFFEL_VERSION},
                                   {DbtRegisterTappi,TAPPI_VERSION},
                                   {DbtRegisterUsers,USERS_VERSION},
               {NULL,"0"}
                                   };

#endif

At the end of the initialising of the array I get an

Building sysadmin.obj.
O:\Mercerie\Acc\AccRegister.h(95): error #2069: Initializer must be constant.
*** Error code: 1 ***
Done.

However on the internet I found such messages to be erroneous errors spawned by the LCC compiler (in a certain version).  

Hope you can set me off in the right direction

Pascal.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: error while compiling
« Reply #1 on: May 03, 2005, 01:21:36 AM »
It might be a bug or a missing odd case - much of the initializer code is different from the original LCC compiler.

I assume the error is at the line: {NULL,"0"}? What is tsRegisterCtrl defined as? Do you have a small "compilable" version of this (with all the proper types - it will of course not really compile because of this problem)?

Pelle
/Pelle

zenonpro

  • Guest
Compile problem
« Reply #2 on: May 04, 2005, 02:39:17 PM »
Well, it's quite a big project to simply send a compilable version.  Keep in mind however that all compiles and runs well with the Metrowerks codewarrior compiler.  And that puzzles me !

/**************************************************************************/
/* Metrowerks professional v4.1                                           */
/**************************************************************************/
/* FILE: PgresTools.h                                                     */
/**************************************************************************/
/* Developed by:           Interchain Belgium NV.                         */
/* Programmer:             ppk                                            */
/* System:                 PentiumII 350/512 64MB                         */
/* Language:               ANSI C                                         */
/* Date of beginning:      30/06/1999                                     */
/* Date of accomplishment:                                                */
/* Version:                1.0.2                                          */
/* Revision History:       None.                                          */
/*                                                                        */
/**************************************************************************/

#ifndef __PGRESTOOLS
#define __PGRESTOOLS

 
 /* Include windows headers */
 
 /* Include application specific headers */
 #include "platform.h"
 #include "MPtoolkit.h"
 #include "ListTools.h"

 /* Include standard headers */
 #include "libpq-fe.h"
 
 /* Constants */
 #define MAXTABLENAME          128
 #define MAXFIELDNAME          128
 #define MAXBLOCKREAD          512

 /* Enumerations */
 
 /* Typedefs */
 typedef struct
 {
  char sHost[32];
  char sPort[32];
  char sDbase[32];
  char sUser[32];
  char sPasswd[32];
  PGconn *prConn;
  PGresult *pErr;
 } tsDbCtrl;
 
 typedef struct
 {
  char *pcQry;
  teBoolean bExecBind;
  teBoolean bExecDefine;
 } tsStatementCtrl;

 typedef struct
 {
  char sFile[MAXDBASENAME];
  char sPcFile[MAXDBASENAME+4];
  int nFile;
  char **sNames;
  int *anWidths;
  tsStatementCtrl *sSelect;
  tsStatementCtrl *sInsert;
  tsStatementCtrl *sUpdate;
  tsStatementCtrl *sDelete;
  void *(*pFncNew)(void);
  char *(*pFncTo)(void *prData);
  void *(*pFncFrom)(char *pcData);
  void (*pFncCheck)(void *prObj);
  void (*pFncErr)(teBoolean);
  void (*pFncInsert)(int,void *);
  void (*pFncDelete)(int,void *);
  void (*pFncUpdate)(int,void *,void *);
  char **(*pFncConvert)(void *prObj);
  void *(*pFncDeconvert)(char **ppcFields);
  void *(*pFncRowConvert)(char *pcRow);
  size_t nSize;
  int nCols;
  tsList *prSelectedRows;
  tsList *pFieldInfo;
  char *pcPrimary;
 } tsTableCtrl;

 
 typedef struct
 {
  tsTableCtrl *(*pFncRegister)(void);
  char sVersion[MAXVERSIONLENGTH];
 } tsRegisterCtrl;


 typedef struct
 {
  char pcName[MAXFIELDNAME];
  teType eType;
  int nSize;
 } tsField;

 typedef struct
 {
  char pcName[MAXFIELDNAME];
  teOrder eOrd;
 } tsKeyField;

 typedef struct
 {
  char pcName[MAXTABLENAME];
  teDb eDatabase;
  tsList *prFields;
  tsList *prIndexes;
  tsList *prViews;
 } tsTable;

 typedef struct
 {
  char pcName[MAXTABLENAME];
  tsList *prKeys;
 } tsIndex;

 typedef struct
 {
  char pcName[MAXTABLENAME];
  char pcSelect[MAXQUERY];
 } tsView;



 /* Macro's */
 
 /* Prototype exported functions */
 DLLEXP tsDbCtrl *DbaNewCtrl(char *pcHost,char *pcPort,char *pcDbase,char *pcUser,char *pcPasswd);
 DLLEXP void DbaSetHandle(tsDbCtrl *prDb);
 DLLEXP tsDbCtrl *DbaGetHandle(void);
 DLLEXP teBoolean DbaConnect(tsDbCtrl *prDb);
 DLLEXP void DbaDisconnect(tsDbCtrl *prDb);
 DLLEXP void DbaCommit(tsDbCtrl *prDb);
 DLLEXP void DbaRollback(tsDbCtrl *prDb);
 DLLEXP tsTable *DbaTableConstruct(char *pcTable);
 DLLEXP teBoolean DbaInsert(tsDbCtrl *prDb,char *pcInsert);
 DLLEXP teBoolean DbaFreeSql(tsDbCtrl *prDb,char *pcSql,void *pData);
 DLLEXP char *DbaExtractTable(char *pcStatement);
 DLLEXP tsList *DbaExtractFields(char *pcStatement);
 DLLEXP int DbaCheckFields(char *pcStatement);

#endif

This is the toolkit header file that declares the 'tsRegisterCtrl' structure.
So basically we initialise an array of register structures with a pointer to a function and a version string.

DLLEXP tsTableCtrl *DbtRegisterArtikels(void)
{
 tsTableCtrl *pT;

 pT = &(rArtikelsCtrl);
 return(pT);
}

This is an example of such a register functions.

Hope this helps.

By the way is pellec C to follow the LCC evolution in version or is it once based on a certain LCC version and become a seperate branch ?

Anyway, keep up the good work the IDE is splendid.  Though I wonder on what basis you extract the functions from the files, because I see that the list of functions is not complete.  There seem to be randomly missing functions.

Pascal.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Compile problem
« Reply #3 on: May 05, 2005, 04:13:47 PM »
Quote from: "zenonpro"
Well, it's quite a big project to simply send a compilable version.

You got the original source code, the error message, and it's line number. I assumed it would be easy for you to narrow the problem down to a few lines of code.

Quote from: "zenonpro"

Keep in mind however that all compiles and runs well with the Metrowerks codewarrior compiler.  And that puzzles me !

I'm not familiar with codewarrior, so this doesn't tell me much of anything.

Quote from: "zenonpro"

This is an example of such a register functions.
Hope this helps.

Not really, as it turned out. I have tried different things (with the 3.00 compiler), but I can't reproduce your error message. For the moment I can only assume the compiler is working as it should...

Quote from: "zenonpro"

By the way is pellec C to follow the LCC evolution in version or is it once based on a certain LCC version and become a seperate branch ?

There have been no active development of LCC for several years, so following it's "evolution" seems rather pointless.

Quote from: "zenonpro"

Anyway, keep up the good work the IDE is splendid.  Though I wonder on what basis you extract the functions from the files, because I see that the list of functions is not complete.  There seem to be randomly missing functions.

Can you be more precise? Again, an example would be helpful...

Pelle
/Pelle

JohnF

  • Guest
error while compiling
« Reply #4 on: May 06, 2005, 05:02:28 PM »
One function type missed in the tree list is this

Code: [Select]

STDMETHODIMP_(ULONG) CContextMenuExt_AddRef(IContextMenu * this)
{
    ContextMenuExtStruct * pCM = (ContextMenuExtStruct*)this;
    return ++pCM->m_ulRef;
}



John

zenonpro

  • Guest
missing functions
« Reply #5 on: May 07, 2005, 02:16:25 PM »
Well in the IDE, when you open a project, you can add files.  To this files the IDE adds a list of header files used by this project.  Also the IDE shows a module source 'c' file as a treeview.  When you expand this treeview you get to see the functions in the 'c' file.  By double-clicking you get the source with the caret located on the function.  I noticed that with several 'c' sources not all functions present in the file are being displayed in the treeview.  But there seems no rule in it, plain random.  Is it perhaps because the sources were merely added to the project, not created within the project ?

Pascal.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
error while compiling
« Reply #6 on: May 08, 2005, 08:20:05 PM »
The problem is with Windows code, and the fact that most things are hidden in M$ macros, typedef's and such. The parser have no time read through all the #include files (to find the proper definitions - this would take forever), only the source file(s), so at certain points in the syntax, some guesswork is required. There is a 50-50 chance of success/failure. If it fails, it will not understand much until it reaches a 'sync point', where things usually starts to work again...

Pelle
/Pelle

zenonpro

  • Guest
functions in the treeview
« Reply #7 on: May 09, 2005, 05:50:39 PM »
I looked more closely to the problem.  I found that the IDE seem to parse the 'c' file well and finds all functions whether they are of type void or some self declared type.   It seemed as if he stopped registering functions after a certain amount of lines, but that was not the case as with one source he stopped at line 750 and with another at line 240 and with some other source at line 625.  But what is practically certain is that with all these files he stopped adding functions to the treeview after say 30000 bytes.  All functions declared  after this limit does not appear in the treeview.  Could it be that this is some buffer problem er so ?

zenonpro

  • Guest
compile problem
« Reply #8 on: May 09, 2005, 06:35:44 PM »
Concerning the compile problem.  I have tried for days to find any errors in my sources but must be overlooking the problem.  I must be doing something that your compiler does not like.  So I looked at it from a different angle, made a new empty project and added just three lines of initialising code.  No matter if I initialise one variable, an array with one element or an array with multiple elements.  I always get the same error, 'initialiser must be constant'.  I also tried with adding the 'const' modifier etc... but no relief.

I sure hope this problem gets solved.

Pascal.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: compile problem
« Reply #9 on: May 09, 2005, 11:29:04 PM »
Quote from: "zenonpro"
Concerning the compile problem.

The problem is with the __declspec(dllimport) attribute on functions like DbtRegisterArtikels. This will actually create a non-constant expression - which isn't allowed for global variables.

The Microsoft compiler (for example) will either reject, or accept with a warning, depending on the version. I guess the warning ("Initializer must be constant") could be better, but there are many variations, so a single message is easier.

Pelle
/Pelle

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: functions in the treeview
« Reply #10 on: May 09, 2005, 11:33:04 PM »
Quote from: "zenonpro"
But what is practically certain is that with all these files he stopped adding functions to the treeview after say 30000 bytes.  All functions declared  after this limit does not appear in the treeview.  Could it be that this is some buffer problem er so ?

I don't have any such buffer in the IDE. I'm pretty sure the SQLite database handler will allocate memory as needed. I guess there could be a limit on the TreeView control itself, on some Windows version (read Win 9X), but I'm not aware of any...

Pelle
/Pelle

zenonpro

  • Guest
Treeview problem
« Reply #11 on: May 10, 2005, 09:05:38 AM »
I'm afraid there is some misunderstanding.  The problem of the treeview I'm talking about is the treeview you use in your IDE to display the project's contents.  Sources, header files etc...  When I click on the + sign of a source.c treeitem, I get to see the functions that are in this 'c' file, but apparently the parser of the IDE does not seem to find all functions in a source.  As I said in the previous posting, it seems as if the parser stops at a certain amount of bytes processed.  As if there is some kind of limitation.  It has nothing to do with my projects, it's simply the IDE.  Just because I find this a great feature, I noticed the flaw.

Pascal.

zenonpro

  • Guest
Concerning the compile problem
« Reply #12 on: May 10, 2005, 09:09:36 AM »
Ah now were getting somewhere, that was something I didn't know.  Is this Pelles C strict or is this a rule that is posed upon C by means of standards.  If so, the old metrowerks worked fine but allowed me to create non-standard things which I find out know. :D

Anonymous

  • Guest
Re: Treeview problem
« Reply #13 on: May 10, 2005, 01:06:16 PM »
Quote from: "zenonpro"
I'm afraid there is some misunderstanding.  The problem of the treeview I'm talking about is the treeview you use in your IDE to display the project's contents.  Sources, header files etc...  When I click on the + sign of a source.c treeitem, I get to see the functions that are in this 'c' file, but apparently the parser of the IDE does not seem to find all functions in a source.  As I said in the previous posting, it seems as if the parser stops at a certain amount of bytes processed.  As if there is some kind of limitation.  It has nothing to do with my projects, it's simply the IDE.  Just because I find this a great feature, I noticed the flaw.

Pascal.


Just a thought... take a look at the folding markers on the left side of the editor windows.  More than once I've discovered bracketing errors because a function is missing from the project tree.  It usually turns out to be a matter of opening 6 braces but only closing 5.  In extreme cases that could make the entire rest of your source code into one big function.

For the most part... when I don't make mistakes, neither does the IDE.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Concerning the compile problem
« Reply #14 on: May 10, 2005, 04:37:49 PM »
Quote from: "zenonpro"
Ah now were getting somewhere, that was something I didn't know.  Is this Pelles C strict or is this a rule that is posed upon C by means of standards.  If so, the old metrowerks worked fine but allowed me to create non-standard things which I find out know. :D

__declspec(dllimport) is not part of any standard - you will most likely see different behaviour with different compilers. Some will just accept the syntax, without doing anything else. In this case it will be easier to accept what you tried to do in your source code.

Pelle
/Pelle