CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 34

Thread: Inexplanable error

  1. #1
    Join Date
    Oct 2003
    Posts
    160

    Inexplanable error

    Hi all,

    I am trying to a compile a piece of code that is guaranteed to be compiled on a unix OS. It is giving me heart burns when I do it for windows. I am using VC++ 6.0.

    There are a bunch of c and h files. Since the code is in C++, I changed the extention of all c files to cpp. One of them named demo1.cpp, appears to be the starting point as indicated by the readme. I just included that file to a newly created project.

    When I compile it, I got the following errors:

    fatal error C1083: Cannot open include file: 'stream.h': No such file or directory
    fatal error C1083: Cannot open include file: 'sys/file.h': No such file or directory
    fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory

    The 3rd error could be removed by changing the directory structure from sys/time.h to time.h. For the first two I just commented them out. I don't know what are those files for and where to get them. If I try to compile it again, I run into the following problem:

    error C2628: '$S17' followed by 'int' is illegal (did you forget a ';'?)

    And the error is pointed to the class definition statement in the following code segment:

    Code:
    struct ComplexDataType{
      void* data;
      int descriptor;
    };
    
    
    class AttId{
    
    public:
    
      AttId();
      AttId(int l,double* v,int d);
    };
    Now this is inexplanable. These are valid c++ statements, and it appears that VC++ can smell that the code was actually intended for unix.

    Please help
    Zeato

  2. #2
    Join Date
    Feb 2000
    Location
    Rennes, France
    Posts
    624

    Re: Inexplanable error

    What is right before this code??

    What is '$S17'?

    This error says you are declaring several things (class, struct, functions) without having a semicolon between them.

    Marina
    Please go vote for your country!

  3. #3
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Inexplanable error

    Quote Originally Posted by dr_zeato

    When I compile it, I got the following errors:

    fatal error C1083: Cannot open include file: 'stream.h': No such file or directory
    fatal error C1083: Cannot open include file: 'sys/file.h': No such file or directory
    fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory
    I think you should use the preprocessor and do something like:
    #if defined (WINDOWS)
    #include <fstream.h>
    #include <time.h>
    #include <stdlib.h>
    #elif defined(UNIX) || defined(LINUX)
    #include <stream.h>
    #include <sys/time.h>
    #include <sys/file.h>
    #endif

    You could always update to:
    #include <fstream>
    #include <ctime>
    etc...but I imagine you are trying to use the same syntax for both UNIX and Windows.
    Quote Originally Posted by dr_zeato

    Now this is inexplanable. These are valid c++ statements, and it appears that VC++ can smell that the code was actually intended for unix.

    Please help
    Zeato
    Possibly a macro mixup. When you clicked on the error message int the output window at the bottom, it should have taken you to the line in question.

    ahoodin

  4. #4
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    Well the following are the entire contents of the file, and the error is at line 9, with the keyword "class".
    Any thoughts?
    Zeato


    Code:
    #ifndef _attobject
    #define _attobject
    #include <stdio.h>
    #include <stddef.h>
    
    
    struct ComplexDataType{
      void* data;
      int descriptor;
    };
    
    
    class AttId{
    
    public:
    
      AttId();
      AttId(int l,double* v,int d);
      AttId(AttId &at);
      ~AttId();
      void set(int l,double* v,int d);
    
      void setComplex(void* data,int descriptor);
    
      AttId operator=(AttId& at);
       AttId operator<(AttId& at);
      AttId operator=(int id);
      int operator==(AttId& at);
      int operator!=(AttId&at);
      int operator==(int id);
      int operator!=(int id);
      
      void write(FILE* file);
      void read(FILE* file);
    
      double operator[](int x);
      int label();
      int length();
      double* Values();
      void* ComplexValue();
    
    
    /* data structures */
      
      ComplexDataType* complex_value;
      double* values;
      int n;
      int Label;
      int ForeignMemory;
    };
      
    extern AttId NO_ATTRIBUTE;
    
    
    #endif

  5. #5
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Inexplanable error

    Move the #includes out of the header file that defines your class and into either the .cpp (preferably .cpp in this case) or the stdafx.h.

    HTH,

    ahoodin

    PS If this post helped, please dont forget to rate. Just click on the scale and click the approve radio button on the dialog that comes up.

  6. #6
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    Quote Originally Posted by ahoodin
    I think you should use the preprocessor and do something like:
    #if defined (WINDOWS)
    #include <fstream.h>
    #include <time.h>
    #include <stdlib.h>
    #elif defined(UNIX) || defined(LINUX)
    #include <stream.h>
    #include <sys/time.h>
    #include <sys/file.h>
    #endif
    Actually I didnt know that stream.h and file.h correspond to fstream.h and stdlib.h respectively. Where can I get a list of such correspondence?
    Thanks
    Zeato

  7. #7
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Inexplanable error

    As for how I came to those decisions, the compiler did not find those libs, so I
    used headers that would work.

    Well the best method would be to go with the new ANSII standard and use:

    #include <iostream>
    #include <fstream>
    #include <ctime>

    The ansii standard is online. Google for that one please.

    ahoodin

  8. #8
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    Quote Originally Posted by ahoodin
    As for how I came to those decisions, the compiler did not find those libs, so I
    used headers that would work.

    Well the best method would be to go with the new ANSII standard and use:

    #include <iostream>
    #include <fstream>
    #include <ctime>

    The ansii standard is online. Google for that one please.

    ahoodin
    Actually, these were not the only files that the compiler complained about. There are several others which might not be that straightforward. For instance, it gives error at #inlcude "osfcn.h". Now I am lost what this file is about.

    Quote Originally Posted by ahoodin
    Move the #includes out of the header file that defines your class and into either the .cpp (preferably .cpp in this case) or the stdafx.h.
    It didnt help. Still the same error, which makes no sense to me.

    Thanks
    Zeato

  9. #9
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Inexplanable error

    #inlcude "osfcn.h"
    This sounds like an OS specific file or a file that is in your UNIX code.

    I am sure from your post that this is a UNIX project. Are you sure you have all your headers from your project? Search for the headers on your UNIX workstation.

    Just dont include them in the MSVC project and see where it chokes, then it should start to be apparent what it is for.

    It didnt help. Still the same error, which makes no sense to me.
    Please post your source in a zip. No object files please.

    ahoodin

  10. #10
    Join Date
    Mar 2001
    Posts
    2,527

    Re: Inexplanable error

    Quote Originally Posted by dr_zeato
    It didnt help. Still the same error, which makes no sense to me.

    Thanks
    Zeato
    additionally move your other includes after the header file with the class declaration in it.

    ahoodin

  11. #11
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    Quote Originally Posted by ahoodin
    Please post your source in a zip. No object files please.

    I copied the files at:
    http://www.geocities.com/dr_zeato/GMT.zip
    Thanks
    Zeato

  12. #12
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Inexplanable error

    There is no "osfcn.h" in the zip file. And please mention which one of those 'C' files do not compile.

    The goal right now is to try to compile a C source file, not build an application.

    Regards,

    Paul McKenzie

  13. #13
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    Quote Originally Posted by Paul McKenzie
    There is no "osfcn.h" in the zip file. And please mention which one of those 'C' files do not compile.

    The goal right now is to try to compile a C source file, not build an application.

    Regards,

    Paul McKenzie
    I copied all files that I had and the readme file says that they compile on UNIX.

    I was trying to compile the file demo1.c. One of the header files uses "osfcn.h" and I know its not there in the zip file. I thought it was some of the standard include files (on UNIX) with some counterpart in VC++ and I had to replace the names, just like ahoodin suggested in his previous posts.

    Am I wrong here?
    Any help/suggestion/pointer would be greatly appreciated.
    Zeato

  14. #14
    Join Date
    Oct 2003
    Posts
    160

    Re: Inexplanable error

    By the way, Google gives the following link to the header file in question:

    http://www.delorie.com/djgpp/doc/incs/osfcn.h

    Zeato

  15. #15
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Inexplanable error

    It is a header file for the djgpp compiler. It is non-standard, and only makes sense for the djgpp compiler.

    Regards,

    Paul McKenzie

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)