Error in compiling .cpp file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Error in compiling .cpp file
# 1  
Old 06-22-2015
Error in compiling .cpp file

I get this error,

Code:
defaults.cpp: In member function ‘int Defaults::GetIntDefault(const std::string&)’:
defaults.cpp:68: error: ‘atoi’ was not declared in this scope
defaults.cpp: In member function ‘real_t Defaults::GetRealDefault(const std::string&)’:
defaults.cpp:76: error: ‘atof’ was not declared in this scope
defaults.cpp: At global scope:
defaults.cpp:8: warning: ‘rcsid’ defined but not used
make: *** [defaults.o] Error 1

when attempting to compile this code:

Code:
int
Defaults::GetIntDefault(  const string& defaultName ) throw ( DfltsErr )
{
    int val;
    val = atoi( GetStringDefault( defaultName ).c_str() );
    return val;
}

real_t
Defaults::GetRealDefault(  const string& defaultName ) throw ( DfltsErr )
{
    real_t val;
    val = atof( GetStringDefault( defaultName).c_str() );
    return val;
}

The file has the following headers (I don't know if they are relevant to this problem):

Code:
#include <ctype.h>
#include <fstream>
#include <sstream>
#include <cstring>
#include "msgdlg.h"
#include "defaults.h"

# 2  
Old 06-22-2015
You need cstdlib - the header where those functions are defined.

Last edited by jim mcnamara; 06-22-2015 at 05:40 PM.. Reason: I cannot type
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Error with shared lIBMpi.so.1 when compiling CPP program

Hello, Met a problem when compiling a C++ program from source code without error, but when ran it there was always an error message: ./Ray: error while loading shared libraries: libmpi_cxx.so.1: cannot open shared object file: No such file or directoryAs the error points to openmpi which was... (0 Replies)
Discussion started by: yifangt
0 Replies

2. Shell Programming and Scripting

Calling a function in cpp file inside shell script

Hi I need to call a function written in a cpp file with arguments inside the shell script..Can anyone help me how to do this:( (1 Reply)
Discussion started by: rkrish
1 Replies

3. Web Development

<Apache>error when compiling CPP modules

Hi, I am working on Linux Platform. I am just trying to port a CPP module to apache as a module. When I try to build the Apache , it throws an error as follows libtool: unrecognized option `-DLINUX=2' Later I did some search and changed the config_vars.mk file under the "build" directory of... (0 Replies)
Discussion started by: ashabb
0 Replies

4. Emergency UNIX and Linux Support

Functions defined in header / cpp file behaves different

File: A.h class A { public: struct x X; int show() { x.member_variable ? 0: -1; } }; Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place... (4 Replies)
Discussion started by: uunniixx
4 Replies

5. Shell Programming and Scripting

want to find out a function name in a cpp file

I have an error in my logs as it shows some function name . 1. I dnt know where is the file.cpp located only i know the machine . 2. How to find out that the function name is loacated in which path and which file into that machine. Thanks . (1 Reply)
Discussion started by: madfox
1 Replies

6. Shell Programming and Scripting

reading a cpp file

I need to find all the methods in a cpp file ... using shell script Pls guide me regarding the grep criteria for searching methods I mean what are the patterns to be grepped in *.cpp which match methods Hope i have made myself clear Thanks and Regards -- Ultimatix (2 Replies)
Discussion started by: ultimatix
2 Replies

7. AIX

[AIX] usages of lint for .cpp file?

Hi , I Want to apply AIX lint to my source code which all are *.cpp/*.h >lint test.cpp lint: 1286-332 File test.cpp must have a .c, .C or .ln extension. It is ignored. lint: 1286-334 There are no files to process. I am getting above error. -Ashok (3 Replies)
Discussion started by: ashokd001
3 Replies

8. Shell Programming and Scripting

If file = .cpp then print?

I'm trying to develop a script that makes it so only .cpp programs can print. I'm doing it for my computer programming class because everyone keeps printing the executable instead of the source code and it's wasting a lot of paper. How can I accomplish this? Thanks for the help. :D (5 Replies)
Discussion started by: Irish_Cereal
5 Replies

9. Programming

Compiling multiple cpp files (abstract factory pattern)

Hi all, I have been working with java for awhile and because of my school projects I needed to switch C++. I tried to implement some patterns in C++ but unfortunately I couldn't. Specifically, I tried to implement abstract factory pattern but since I used separated files (habitual behavior from... (4 Replies)
Discussion started by: SaTYR
4 Replies
Login or Register to Ask a Question