Author Topic: Error  (Read 3955 times)

tiutea

  • Guest
Error
« on: September 13, 2016, 10:37:12 am »
I tried example from Prata book and got error
CODE:

Code
#include<iostream>
#include <ctime>
#include <cstdlib>
#include "String.h"
const int MIN_PER_HR=60;
bool newcustomer(double x);
int main(){
    using namespace std;
    srand(time(0));

    return 0;
}


P.S. downloaded and installed codeblocks 16.01 on Win7




ERROR


||=== Build: Debug in book (compiler: GNU GCC Compiler) ===|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|60|error: '::clock_t' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|64|error: '::clock' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|65|error: '::difftime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|66|error: '::mktime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|67|error: '::time' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|68|error: '::asctime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|69|error: '::ctime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|70|error: '::gmtime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|71|error: '::localtime' has not been declared|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\ctime|72|error: '::strftime' has not been declared|
D:\z\book\main.cpp||In function 'int main()':|
D:\z\book\main.cpp|9|error: 'time' was not declared in this scope|
||=== Build failed: 11 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
« Last Edit: September 14, 2016, 09:59:32 am by tiutea »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Error
« Reply #1 on: September 13, 2016, 05:08:30 pm »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Error
« Reply #2 on: September 13, 2016, 05:29:46 pm »
I suggest posting a build log in code tags instead of build messages.

I also suggest removing the include of "String.h".

http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org