DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28

Thread: Unexpected End of File

  1. #16
    Join Date
    Nov 2003
    Posts
    4,118
    Using C++ BuilderX, I didn't encounter this error but I ecnountered many other compilation errros which pertain to syntax errors. First, in one of the declarations of BooleanConstant::forValue you have a syntax error. You declare it:
    BooleanConstant::BooleanConstant *forValue()

    instead of
    BooleanConstant * BooleanConstant::forValue();

    This isn't all: I don't see why you need this class in the first place. Worst yet, you're using the symbols TRUE and FALSE as variables names which is a very bad idea because I'm almost certain that every compiler these days still retains these names as macros from the pre-bool era, which might explain why the preprocessor chokes. Finally, I don't see why a class called BooleanConstants should have a base class. Notice also:

    public:
    static bool* forValue(bool b);
    };

    you declare here a static member function that returns a non static member called _b. This is illegal.

    In short, what I suugest is that you simplify this project, remove all instances of "over-engineering" (such as having a class whose sole purpose is to return a bool variable, using static data members as constants instead of using the keywords true and false etc.) and then compile this project. VS 2003 isn't a perfect compiler but I'm sure it can hjandle three header files.
    The fact that GCC compiled this code doesn't promise much. You got linkage errors which suggest that something isn't defined in the project, hence, you still have to add definitions of the static data members (you only declare them).
    Danny Kalev

  2. #17
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    Danny, i used last code evlich send (12. message ) with modifications (#include parts changed ).
    both first and second without modifications had troubles in gcc too.

  3. #18
    Join Date
    Nov 2003
    Posts
    4,118
    OK, using these modified source files (precisely) with C++ BuilderX, everything compiles and links just fine. Evlich, try to use these files and make sure that your compiler doesn't sneak in its usual follies: precopiled headers and "stdafx.h". Note also that I added main() to the .cpp file.
    mr1yh1, does this project compile under GCC?

    1:
    Code:
    #ifndef __AST_H__
    #define __AST_H__
    
    class ASTVisitor;
    
    class AST {
    public:
    	virtual void process(ASTVisitor &visitor) = 0;
    };
    
    #endif
    2:
    Code:
    #ifndef __AST_VISITOR_H__
    #define __AST_VISITOR_H__
    class BooleanConstant;
    
    class ASTVisitor {
    protected:
    	ASTVisitor();
    
    public:
    	/** Constant Constructions **/
    	virtual void forBooleanConstant(BooleanConstant *boolConst) = 0;
    };
    
    #endif
    3:

    Code:
    #ifndef __BOOLEAN_CONSTANT_H__
    #define __BOOLEAN_CONSTANT_H__
    
    
    
    class BooleanConstant : public AST {
    private:
    	bool _value;
    	static BooleanConstant _TRUE;
    	static BooleanConstant _FALSE;
    
    public:
    	bool getValue();
    	virtual void process(ASTVisitor &visitor);
    
    protected:
    	BooleanConstant(bool value);
    	virtual ~BooleanConstant();
    public:
    	static const BooleanConstant* forValue(bool b);
    };
    
    #endif
    4:

    Code:
    #ifndef __BOOLEAN_CONSTANT_CXX__
    #define __BOOLEAN_CONSTANT_CXX__
    
    
    #include "AST.h"
    #include "ASTVisitor.h"
    #include "BooleanConstant.h"
    
    
    BooleanConstant::BooleanConstant(bool b) {
    	_value = b;
    }
    
    BooleanConstant::~BooleanConstant() {
    }
    
    void BooleanConstant::process(ASTVisitor &visitor) {
    	visitor.forBooleanConstant(this);
    }
    
    const BooleanConstant* BooleanConstant::forValue(bool b) {
    	if( b ) {
    		return &BooleanConstant::_TRUE;
    	} else {
    		return &BooleanConstant::_FALSE;
    	}
    }
    
    int main()
    {}
    #endif
    Danny Kalev

  4. #19
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    ...
    Last edited by mr1yh1; 11-21-2005 at 03:45 PM. Reason: i misundertood

  5. #20
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    i edited post a lot of times becos of wrong copy paste. :D

    yes it compilied.
    same 2 link errors:
    undefined reference to `BooleanConstant::_TRUE'
    ..
    Last edited by mr1yh1; 11-21-2005 at 03:49 PM.

  6. #21
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    Danny ,did you try it with a seperate main.cpp .
    with
    # include "BooleanConstant.h"

    there are problems in gcc :
    BooleanConstant.h:8: error: expected class-name before '{' token
    ...

  7. #22
    Join Date
    Nov 2003
    Posts
    4,118
    No I used it with once .cpp file that has main() in it. The linkage errors are not a problem at the moment because they are quite expected: the program doesn't define the static data members TRUE and FALSE, it only delcares them which is of course an error, but the original problem was getting the sources to compile.
    Danny Kalev

  8. #23
    Join Date
    Aug 2003
    Posts
    313
    I cleaned up all the linker errors and such, I still have no idea as to why VC++ is ignoring some of my includes (I told it to generate an include file, and it said that the only thing that I was including was AST.h, the first one, even though I had more includes after that). My guess is that this is a configuration problem with my project, but I don't really know.
    ~evlich

  9. #24
    Join Date
    Dec 2003
    Posts
    3,366
    You have to #include .h files. Simply creating them does nothing. Adding them to the project also does nothing, or at most it checks the syntax.

  10. #25
    Join Date
    Nov 2003
    Posts
    4,118
    Also, you want to clean the current project settings and any remnants of incremental builds. Simply use the Rebuild All option.
    Danny Kalev

  11. #26
    Join Date
    Nov 2005
    Posts
    1
    place the curson after the last character you typed in the header file and hit enter to insert a newline character

  12. #27
    Join Date
    Aug 2003
    Posts
    313
    The newlines did it. Thanks a lot everyone.
    ~evlich

  13. #28
    Join Date
    Dec 2003
    Posts
    3,366
    Then your problem is you have a setup that does partial compiles (it thinks it knows what has changed and only re-compiles those files). Just do a "rebuild all" from your IDE, extra end of lines works(usually) but you might miss a file and it takes way too long.

Similar Threads

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 12:18 PM
  2. How to save changes to a msflexgrid
    By Tommy in forum VB Classic
    Replies: 0
    Last Post: 06-23-2002, 03:15 PM
  3. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 05:23 AM
  4. NT Authentication within VB app
    By Amy in forum VB Classic
    Replies: 10
    Last Post: 12-21-2000, 12:21 AM
  5. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 2
    Last Post: 08-11-2000, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center