Welcome! Log In Create A New Profile

Advanced

Compile time error

Posted by bobj 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Compile time error
March 08, 2006 01:22PM
In reponse to Vaughn's query below.

1. When you declare you Bank_impl class you make reference to something called a POA_Bank. The compiler has no idea what a POA_Bank is so it indicates a syntax error. You will see that the POA_Bank class is actually declared in the Bank.h file which was generated by the idl compiler. Thus in order to implement a Bank_impl class you must '#include "Bank.h"' at the top of your file. This is why the idl compiler generated the file in the first place - so you can inherit from generated classes and hence ensure type safety.

2. The problem with Bank_impl.cc should go away when you solve the first problem.

A final suggestion. Do yourself a favour and add the --c++-impl flag to your IDL compiler flags. This will autogenerate a correctly structured Bank_impl.h and Bank_impl.cc file which you can then edit and flesh out with functionality.

regards
Bob


>Vaughn wrote:
I just seems to run into errors in this course.

I got the makefile to work but now it says I have syntax errors
which I dont think I have.

g++ -D_REENTRANT -DHAVE_ANSI_CPLUSPLUS_HEADERS -Wall -mthreads -Ic:/unisa/mico/i
nclude -c -o Bank_impl.o Bank_impl.cc
In file included from Bank_impl.cc:2:
Bank_impl.h:6: parse error before `{' token
Bank_impl.cc:5: syntax error before `::' token
Bank_impl.cc:16: parse error before `=' token
Bank_impl.cc:17: `CORBA' was not declared in this scope
Bank_impl.cc:17: parse error before `::' token
Bank_impl.cc:17: ISO C++ forbids declaration of `assert' with no type
gmake: *** [Bank_impl.o] Error 1

// File: Bank_impl.h
#ifndef BANK_IMPL_H
#define BANK_IMPL_H
class Bank_impl:virtual public POA_Bank
{
public:
Account_ptr create ();
};
#endif


// File Bank_impl.cc
#include "Bank_impl.h"
Account_ptr
Bank_impl::create ()
{
/*
* Create a new account (which is never deleted)
*/
Account_impl * ai = new Account_impl;
/*
* Obtain a reference using _this. This implicitely activates the
* account servant (the RootPOA, which is the object’s _default_POA,
* has the IMPLICIT_ACTIVATION policy)
*/
Account_ptr aref = ai->_this ();
assert (!CORBA::is_nil (aref));
/*
* Return the reference
*/
return aref;
}
Sorry, only registered users may post in this forum.

Click here to login