C++ Exception class missing?


 
Thread Tools Search this Thread
Top Forums Programming C++ Exception class missing?
# 1  
Old 06-06-2012
C++ Exception class missing?

Hi

I tried googling about it and I couldn't really find a solid answer. Why is the compiler missing the exception class when it seems to be a standard class?

The code is here:
Code:
//Rijndael.h
 
#ifndef __RIJNDAEL_H__
#define __RIJNDAEL_H__
#include <exception>
#include <cstring>
using namespace std;
 
//Rijndael (pronounced Reindaal) is a block cipher, designed by Joan Daemen and Vincent Rijmen as a candidate algorithm for the AES.
//The cipher has a variable block length and key length. The authors currently specify how to use keys with a length
//of 128, 192, or 256 bits to encrypt blocks with al length of 128, 192 or 256 bits (all nine combinations of
//key length and block length are possible). Both block length and key length can be extended very easily to
// multiples of 32 bits.
//Rijndael can be implemented very efficiently on a wide range of processors and in hardware. 
//This implementation is based on the Java Implementation used with the Cryptix toolkit found at:
//http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael.zip
//Java code authors: Raif S. Naffah, Paulo S. L. M. Barreto
//This Implementation was tested against KAT test published by the authors of the method and the
//results were identical.
class CRijndael
{
public:
...
...
...
public:
    //CONSTRUCTOR
    CRijndael();
    //DESTRUCTOR
    virtual ~CRijndael();
    //Expand a user-supplied key material into a session key.
    // key        - The 128/192/256-bit user-key to use.
    // chain      - initial chain block for CBC and CFB modes.
    // keylength  - 16, 24 or 32 bytes
    // blockSize  - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
    void MakeKey(char const* key, char const* chain, int keylength=DEFAULT_BLOCK_SIZE, int blockSize=DEFAULT_BLOCK_SIZE);
private:
    //Auxiliary Function
    void Xor(char* buff, char const* chain)
    {
        if(false==m_bKeyInit)
            throw exception(sm_szErrorMsg1);
        for(int i=0; i<m_blockSize; i++)
            *(buff++) ^= *(chain++);    
    }

And the error when trying to compile:

Code:
Rijndael.h: In member function 'void CRijndael::Xor(char*, const char*)':
Rijndael.h:78: error: no matching function for call to 'std::exception::exception(const char*&)'
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/exception:57: note: candidates are: std::exception::exception()
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/exception:55: note:

anyone run into a similar issue? is my gcc missing the exception class? it is
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)

Thanks for your help
# 2  
Old 06-06-2012
Do you have using namespace std; anywhere in your code? Without that you might need to do std::exception
# 3  
Old 06-08-2012
Quote:
Originally Posted by Corona688
Do you have using namespace std; anywhere in your code? Without that you might need to do std::exception
yes, it is under the includes.

any ideas?
# 4  
Old 06-08-2012
What is sm_szErrorMsg1 ? I don't think you can directly throw strings into an exception like that. Integers probably, and classes derived from the exception class, but not raw strings.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 06-08-2012
thanks, i removed it and it seems to bypass that error. however many more came out and i guess i will slowly debug each of them.

just a side thing, i grabbed the code verbatim from Downloads: A C++ Implementation of the Rijndael Encryption/Decryption method - CodeProject

i dont understand why a highly rated article has code that is not able to be used right out of the box? anyone have a better (working) implementation of Rijndael?
# 6  
Old 06-08-2012
That code was written for Microsoft Windows in Visual C++ 6, and Microsoft compilers and libraries tend to have many nonstandard features and extensions. Portably-written code will usually compile in a Microsoft compiler, but programmers who don't know better can make code written in Microsoft compilers very hard to port. Things like this:

Code:
for(int i=0; i<10; i++) { ... }

Declaring variables inside a for-loop like this used to be a nonstandard feature, and caused many headaches for programmers trying to port code written in Visual C++.
# 7  
Old 06-08-2012
You can find Rijndael(i.e. AES) encryption algorithms inside the source code for OpenSSL.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

2. Red Hat

Yum - resolving missing dependencies that are not missing

I am trying to install VirtualBox on RHEL 5 but I need the 32 bit version for 32 bit Windows. When I run yum I get the following: sudo yum localinstall /auto/spvtg-it/spvss-migration/Software/VirtualBox-4.3-4.3.2_90405_el6-1.i686.rpm Loaded plugins: fastestmirror Setting up Local Package... (13 Replies)
Discussion started by: gw1500se
13 Replies

3. SuSE

How to resolve missing missing dependencies with opensuse 11.3 and 12.3?

Hello, This is a programming question as well as a suse question, so let me know if you think I should post this in programming. I have an application that I compiled under opensuse 12.2 using g77-3.3/g++3.3. The program compiles and runs just fine. I gave the application to a colleague who... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

4. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

5. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies

6. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

7. Programming

static use for class inside the same class c++

Hi, I believe the next code is wrong: class Egg { Egg e; int i; Egg(int ii=0) : i(ii) {} }; because you would end up with an endless definition (memory allocation) of Egg objects, thus int i. Ok, so God Eckel proposes for a singleton: class Egg { static Egg e; int... (5 Replies)
Discussion started by: xavipoes
5 Replies

8. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

9. UNIX for Dummies Questions & Answers

car class (not school class)

im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
Discussion started by: rickym2626
1 Replies

10. UNIX for Dummies Questions & Answers

Exception while loading DB2 driver Class.forName("com.ibm.db2.jcc.DB2Driver")

Hi... I m working on UNIX z/OS. Actually i have to pass the parameters from the JCL to java-db2 program thru PARM. I am able to pass the arguments but the problem occured is, it is throwing an exception while loading the db2 driver as 'Javaclassnotfound:com.ibm.db2.jcc.DB2Driver'... (0 Replies)
Discussion started by: Sujatha Gowda
0 Replies
Login or Register to Ask a Question