Problem with isaac during compliation

Since I first posted this in the beginners section, but was recommended to try a different section, ill just copy/paste what i had there.
When ever i try using the isaac template class (here: http://burtleburtle.net/bob/cplus/isaac.hpp)
I always seem to get this compile-time error:
1
2
3
4
5
[natman3400@nathan pixl]$ g++ main.cc -o main -lcryptopp
In file included from main.cc:8:0:
isaac.hpp: In member function ‘virtual void QTIsaac<ALPHA, T>::randinit(QTIsaac<ALPHA, T>::randctx*, bool)’:
isaac.hpp:162:14: error: name lookup of ‘i’ changed for ISO ‘for’ scoping [-fpermissive]
isaac.hpp:162:14: note: (if you use ‘-fpermissive’ G++ will accept your code)


trying -fpermissive gives me this:

1
2
3
4
5
[natman3400@nathan pixl]$ g++ main.cc -o main -lcryptopp -fpermissive
In file included from main.cc:8:0:
isaac.hpp: In member function ‘virtual void QTIsaac<ALPHA, T>::randinit(QTIsaac<ALPHA, T>::randctx*, bool)’:
isaac.hpp:162:14: warning: name lookup of ‘i’ changed for ISO ‘for’ scoping [-fpermissive]
isaac.hpp:153:15: warning:   using obsolete binding at ‘i’ [-fpermissive]


and this is the code i am trying to run:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include </usr/include/cryptopp/sha.h>
#include <iostream>
#include <string>
#include </usr/include/cryptopp/hex.h>
#include <sstream>
#include </home/natman3400/pixl/BigIntegerLibrary.hh>
#include </home/natman3400/pixl/BigInteger.hh>
#include "isaac.hpp"
using namespace std;

int main()
{
 QTIsaac<8,ISAAC_INT> herp;
 std::string digest;
 std::string digest2;

CryptoPP::SHA512 hash;  // don't use MD5 anymore. It is considered insecure

// Thank you, Wei Dai, for making this possible:
string mystr;
cout << "Input the desired string to be hashed" << "\n";
getline (cin, mystr);
CryptoPP::StringSource foo(mystr, true,
   new CryptoPP::HashFilter(hash,
      new CryptoPP::HexEncoder (
         new CryptoPP::StringSink(digest))));
CryptoPP::StringSource foo2(mystr, true,
   new CryptoPP::HashFilter(hash,
         new CryptoPP::StringSink(digest2)));
char *derp = (char*)digest2.c_str();
for(int i =0;i<32;i++){
 derp[i]=(char)(abs((int)derp[i])); 
}
std::cout << derp << std::endl;
std::cout << digest << std::endl;
  
  return 0;
}


Thank you in advance for any help you can offer.
I expect it builds with -fpermissive. Warnings do not stop it building.
This makes me suspect i might have a problem with my g++, as it is not building(or at least not saving the file where i tell it too), ill try re-installing it.
Some how doing a yum reinstall helped.
Problem solved.
Now how do i seed this thing...
No I am on my laptop, and a different problem is arising:
/home/natman3400/cpp/res/isaac.hpp:80:60: error: ‘NULL’ was not declared in this scope
/home/natman3400/cpp/res/isaac.hpp: In constructor ‘QTIsaac<ALPHA, T>::randctx::randctx()’:
/home/natman3400/cpp/res/isaac.hpp:57:27: error: ‘::malloc’ has not been declared
/home/natman3400/cpp/res/isaac.hpp:58:27: error: ‘::malloc’ has not been declared
/home/natman3400/cpp/res/isaac.hpp: In destructor ‘QTIsaac<ALPHA, T>::randctx::~randctx()’:
/home/natman3400/cpp/res/isaac.hpp:63:13: error: ‘::free’ has not been declared
/home/natman3400/cpp/res/isaac.hpp:64:13: error: ‘::free’ has not been declared
/home/natman3400/cpp/res/isaac.hpp: In member function ‘virtual void QTIsaac<ALPHA, T>::srand(T, T, T, T*)’:
/home/natman3400/cpp/res/isaac.hpp:117:33: error: ‘NULL’ was not declared in this scope
/home/natman3400/cpp/res/isaac.hpp: In member function ‘virtual void QTIsaac<ALPHA, T>::randinit(QTIsaac<ALPHA, T>::randctx*, bool)’:
/home/natman3400/cpp/res/isaac.hpp:162:14: error: name lookup of ‘i’ changed for ISO ‘for’ scoping [-fpermissive]
/home/natman3400/cpp/res/isaac.hpp:162:14: note: (if you use ‘-fpermissive’ G++ will accept your code)


I have a feeling that this is something i am just missing due to my being new to c++
Im really scratching my head with this one.
The first problem is in the header you are including. If you look at it on line 162 as the compiler is telling you, you see:

1
2
for(i=0; i < N; i+=8)
// ... 


But the variable i haven't been declared before. It appears inside a for loop on line 153:

1
2
for(int i=0; i < 4; ++i)
// .. 


So you have to either edit the header file or use -fpermissive. But the problem is with the person who wrote it, not you.

Edit

Oh, and about the second error, add

1
2
3
4
#include <cstdlib>
using std::malloc;
using std::free;
using std::NULL; // not sure if this one is necessary 


before you include the header.
Last edited on
Topic archived. No new replies allowed.