NO

Author Topic: Multiple compiler errors not resolved with /Ze option  (Read 11335 times)

kamesh001

  • Guest
Multiple compiler errors not resolved with /Ze option
« on: September 08, 2012, 09:07:29 PM »
I'm trying to compile the swiss ephemeris source files (astronomical calculations for determining planetary positions) to create a DLL. The documentation (http://www.astro.com/swisseph/swephprg.htm) clearly states that the code is Ansi C and in most cases the user will compile a linkable or shared library from the source code, using his favorite C compiler, and then link this library with his application.
If the user programs in C, he will only need to include the header file swephexp.h with his application; this in turn will include sweodef.h. All other source files can ignored from the perspective of application development.

So I downloaded the files and tried to compile them using Pelles C compiler with the /Ze option turned on

but I'm still getting

C:\Program Files\PellesC\Include\Win\objidl.h(2261): fatal error #2210: More than 100 errors, please improve yourself.
If you are compiling a Windows program, make sure you use the /Ze option!

It doesn't matter what file I try to compile, the errors always start with the following lines:

C:\Program Files\PellesC\Include\Win\objidl.h(500): error #2001: Syntax error: expected '}' but found 'COAUTHINFO'.
C:\Program Files\PellesC\Include\Win\objidl.h(502): error #2156: Unrecognized declaration.
C:\Program Files\PellesC\Include\Win\objidl.h(502): warning #2099: Missing type specifier; assuming 'int'.
C:\Program Files\PellesC\Include\Win\objidl.h(1016): error #2001: Syntax error: expected '}' but found 'COSERVERINFO'.
C:\Program Files\PellesC\Include\Win\objidl.h(1017): error #2156: Unrecognized declaration.

I attached the the swetest.c file and the two header files needed to reproduce the errors. I'm using the latest 7.0 version of the Pelles C compiler.

I have successfully used Pelles C with most of my other C programs and found it a fantastic compiler and I'm now stuck as I cannot link in these source files for my project. Would really appreciate some pointers on how to fix this problem

Thanks in advance for any help.



aardvajk

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #1 on: September 08, 2012, 11:37:36 PM »
For some reason, whoever wrote it thought it'd be a great idea to include the Windows headers in a backward fashion. Find the Windows.h include (I've forgotten which .h file its in) and stick it at the top of that section above wtypes.h. You'll then have 2 errors, so look in the Pelles help file for which header includes getcwd, and replace the dos.h include (which doesn't exist) with what you found.

kamesh001

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #2 on: September 09, 2012, 04:11:33 AM »
Thanks a bunch. That resolved the issue! There's a separate issue with floating point expressions which I will post separately.

rogernick

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #3 on: September 09, 2012, 12:10:11 PM »
For some reason, whoever wrote it thought it'd be a great idea to include the Windows headers in a backward fashion. Find the first Windows.h include (I've forgotten which .h file its in) and stick it at the top of that section above wtypes.h. You'll then have 2 errors, so look in the Pelles help file for which header includes getcwd, and replace the dos.h include (which doesn't exist) with what you found.

sorry to interrupt. I'm a beginner and so interested in learning from others like you. Well, why do you ask him to include something that just doesn't exist? Will that produce some interesting output?.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Multiple compiler errors not resolved with /Ze option
« Reply #4 on: September 09, 2012, 12:17:32 PM »
Try to use compiler preprocessor defines WIN32 _WINDOWS WIN32_LEAN_AND_MEAN
and MAKE_DLL or USE_DLL

windows.h is needed only in swedllst.c ?
you can insert
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
to that file (swedllst.c) and remove those from all another files.
« Last Edit: September 09, 2012, 01:48:44 PM by timovjl »
May the source be with you

CommonTater

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #5 on: September 09, 2012, 03:14:19 PM »
You'll then have 2 errors, so look in the Pelles help file for which header includes getcwd, and replace the dos.h include (which doesn't exist) with what you found.

sorry to interrupt. I'm a beginner and so interested in learning from others like you. Well, why do you ask him to include something that just doesn't exist? Will that produce some interesting output?.

Hi rogernick,
Read aardvajk's instructions again...
 
1) Look in the help file to find the include file with getcwd.
2) Replace dos.h with that file.
 
... because dos.h doesn't exist in Pelles C. 
 
Soooo... open POIDE start a new source page and type getcwd then press F1
Or... click Help -> Contents -> Index and type getcwd into the entry bar.
 
If Pelles C has no other strengths, it has just about the best help file I've ever seen.
 
You will discover getcwd() is not a standard C function.  It's name is thus prefixed with an underscore, per Pelle's policy, so the source needs to be edited to call _getcwd and the pages that use it need to include direct.h 
 
 
« Last Edit: September 09, 2012, 03:17:23 PM by CommonTater »

CommonTater

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #6 on: September 09, 2012, 03:35:47 PM »
I'm trying to compile the swiss ephemeris source files

A couple of small points in addition to the other's comments, if I may...

1) That has to be just about the most poorly formatted code I've seen in a long long time.  It would do you a world of good to reformat it into something more like today's standards before going too much further.  The reformatting will both familiarize you with the code and make it far more readable should you have to do touchups.

2) You can take a hint from the frequent  #if MSDOS  macros.  This is old school DOS code that may contain functions and calls not present in Windows compilers like Pelles C, or present under a different name.   You may need to do some modifications to get it to compile for Windows Console mode.  In particular I noticed that one of the includes you need (direct.h) is buried under an #if MSDOS define that will not be active in Pelles C. 

3) Given #2 you might try defining MSDOS in your project settings ... Project -> Project Options -> Compiler -> Defines and see what happens.  You will likely still need to do some fixups but this should provide you some strong clues on the directions you need to take.

4) You would likely fair better if you were compiling this as a Static Library rather than a DLL ... DLL's need special handling of exported and imported functions that are not included in your present source code.

Good luck with this... By all appearances it's a challenging project. 

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Multiple compiler errors not resolved with /Ze option
« Reply #7 on: September 09, 2012, 04:30:08 PM »
You will discover getcwd() is not a standard C function.  It's name is thus prefixed with an underscore, per Pelle's policy, so the source needs to be edited to call _getcwd and the pages that use it need to include direct.h
Or use compiler option -Go Define compatibility names.
May the source be with you

CommonTater

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #8 on: September 09, 2012, 04:41:20 PM »
You will discover getcwd() is not a standard C function.  It's name is thus prefixed with an underscore, per Pelle's policy, so the source needs to be edited to call _getcwd and the pages that use it need to include direct.h
Or use compiler option -Go Define compatibility names.

Thanks Timo.... I forgot to mention that.




kamesh001

  • Guest
Re: Multiple compiler errors not resolved with /Ze option
« Reply #9 on: September 10, 2012, 01:09:03 PM »
You will discover getcwd() is not a standard C function.  It's name is thus prefixed with an underscore, per Pelle's policy, so the source needs to be edited to call _getcwd and the pages that use it need to include direct.h
Or use compiler option -Go Define compatibility names.

Thanks Timo.... I forgot to mention that.

Adding the compiler option -Go Define compatibility names did the trick. The project compiles perfectly now. Thanks everyone for your comments and solutions. Very helpful. This is a great forum!