|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hy all
I am trying to make .exe from .cpp but having some problem. When i type c++ cron.cpp -o cron.exe i get following error In file included from /usr/include/c++/4.1.0/backward/iostream.h:31, from cron.cpp:1: /usr/include/c++/4.1.0/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. cron.cpp:16:10: error: token "[" is not valid in preprocessor expressions cron.cpp:18:1: error: unterminated #if cron.cpp:16:1: error: unterminated #if cron.cpp: In function ‘int main()’: cron.cpp:15: error: expected `}' at end of input cron.cpp:15: error: label ‘FINAL’ used but not defined in my cpp file is the following code #include <iostream.h> #include <stdlib.h> #include <fstream.h> main(){ START: system("clear"); cout<<"MeteOS"<<endl; //#include "logo.h" cout<<"Waiting for startup time..."<<endl; system("date -u > /meteos/util/log/cron.log"); ifstream file_cron_log("/meteos/util/log/cron.log"); char line[255]; file_cron_log.getline(line, 255); file_cron_log.close(); if((line[11]=='0')&&(line[12]=='5')&&(line[14]=='0')&&(line[15]=='0')){system("slosky");goto FINAL;} #if((line[11]=='1')&&(line[12]=='1')&&(line[14]=='0')&&(line[15]=='0')){system("slosky");goto FINAL;} if((line[11]=='1')&&(line[12]=='7')&&(line[14]=='0')&&(line[15]=='0')){system("slosky");goto FINAL;} #if((line[11]=='2')&&(line[12]=='3')&&(line[14]=='0')&&(line[15]=='5')){system("slosky");goto FINAL;} FINAL: system("sleep 60"); goto START; } |
|
|||
|
# is not a comment character, it's the start of a preprocessor line. If you want to comment out those if lines, use //.
|
|
|||
|
Don't feel bad, dude!
I'm a programmer by trade, and when I've been using python, and then go back to C, I usually make the same mistake. But I've learned to read the compiler error messages to find out what went wrong! |
|
|||
|
hi tevz
about your question ( compiler error ) Code:
/usr/include/c++/4.1.0/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. cron.cpp:16:10: error: token "[" is not valid in preprocessor expressions cron.cpp:18:1: error: unterminated #if cron.cpp:16:1: error: unterminated #if cron.cpp: In function ‘int main()’: cron.cpp:15: error: expected `}' at end of input cron.cpp:15: error: label ‘FINAL’ used but not defined as [ ken_yap ] he said before # is not used for comment in c++ use // for one line or // for multiple lines by ignoring the '\n' line character ex: // this programme used to illustrate\ |
|
|||
|
hi tevz
about your question ( compiler error ) Code:
(1) /usr/include/c++/4.1.0/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. cron.cpp:16:10: error: token "[" is not valid in preprocessor expressions (2) cron.cpp:18:1: error: unterminated #if cron.cpp:16:1: error: unterminated #if (3) cron.cpp: In function ‘int main()’: cron.cpp:15: error: expected `}' at end of input cron.cpp:15: error: label ‘FINAL’ used but not defined about this warning you can disable it by set all identifiers of std to global name space ex: #include<iostream.h> using namespace std; it's mean now cout the object of ostream and cin of istream and all variables in std name space become global now (2) as [ ken_yap ] he said before # is not used for comment in c++ use // for one line or // for multiple lines by ignoring the '\n' line character ex: // this programme used to illustrate\ comment or the standard /* comment body for multiple lines */ (3) you used FINAL label before declaring it ex: FINAL: exec -> statement ; goto FINAL; but loops is more efficient for this purpose (4) about using of system () it's not very good because it's use exevd(const char* path ,char ** parameters); to execute new sub shell for you but if you didn't install specific gnu tool and used it in system() in this case system will return non zero value ex: system ("date +%T >/mnt/time.log"); lets assume you didn't install gnu date programme now the sub shell will creat new file but it will't redirect any thing so it's more efficient to use the linux apis to access time such localtime() time() ctime() you will it's doc in the system's call's doc i wish that i helped you buy |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|