Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C++ help compiling CmdLine

Posted on 2009-05-04
10
Medium Priority
?
589 Views
Last Modified: 2013-11-17
Hi All, I need help compiling and building CmdLine (http://www.cmcrossroads.com/bradapp/ftp/src/libs/C++/CmdLine.html) on my Redhat linux server here. I tried but ran into the following error...

$ make library
for i in src ; do \
                ( cd $i ; make - "FLAG=-O" "TESTDEFS=" "USRDEFS=-DDEBUG_CMDLINE" "OPTIONS=" library ) ; \
        done
make[1]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src'
for i in lib ; do \
                ( cd $i ; make -w -- OPTIONS= USRDEFS=-DDEBUG_CMDLINE TESTDEFS= FLAG=-O "FLAG=-O" "TESTDEFS=" "USRDEFS=-DDEBUG_CMDLINE" "OPTIONS=" library ) ; \
        done
make[2]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
make[2]: Warning: File `cmdline.h' has modification time 81 s in the future
g++ -O -I./  -DDEBUG_CMDLINE  -Dunix_style  -c argiter.c
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward/iostream.h:31,
                 from argiter.c:13:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/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.
cmdline.h:24: error: using typedef-name â¬Üstd::ostreamâ¬" after â¬Üclassâ¬"
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:138: error: â¬Üstd::ostreamâ¬" has a previous declaration here
cmdline.h:25: error: using typedef-name â¬Üstd::istreamâ¬" after â¬Üclassâ¬"
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:137: error: â¬Üstd::istreamâ¬" has a previous declaration here
make[2]: *** [argiter.o] Error 1
make[2]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
make[1]: *** [library] Error 2
make[1]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src'
make: *** [library] Error 2
[CmdLine]

thanks for your help in advance.

Nishant

0
Comment
Question by:wevouch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
10 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 24294377
Are you #include-ing the deprecated <iostream.h>, rather than <iostream> ?
0
 

Author Comment

by:wevouch
ID: 24294391
Yes, I think the CmdLine code base is using iostream.h
But that usually only results in a warning right?
0
 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 1800 total points
ID: 24294411
And in cmdline.h, these two lines :

>> class  ostream ;
>> class  istream ;

should not be there. instead, you can add this #include :

        #include <iosfwd>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 1800 total points
ID: 24294437
>> Yes, I think the CmdLine code base is using iostream.h
>> But that usually only results in a warning right?

It is just a warning, yes (which can be disabled using -Wno-deprecated if you want to).
But it is an indication that the code is ancient (ie. written before the C++ standard), and should possibly be ported.

You can try getting it to run like this, but the two errors re. the ostream and istream forward declarations can't be resolved without modifying the code.

So, either you use the proper <iostream> header, and modify the code accordingly (and make the modification from my previous post).
Or, you fix the errros by looking up the proper forward declarations for the ostream and istream types (look in the iostream.h header file for your compiler).
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1800 total points
ID: 24294479
Or maybe, using a different option parser, like getopt is an option ?

        http://www.gnu.org/software/hello/manual/libc/Getopt.html
0
 

Author Comment

by:wevouch
ID: 24294646
I like the interface for CmdLine, so I want to give it a shot before I try getopt.
I changed all occurances of #include <iostream.h> to $include <iostream>.
Now I get...

$ sudo make all
for i in src doc ; do \
                ( cd $i ; make - "FLAG=-O" "TESTDEFS=" "USRDEFS=-DDEBUG_CMDLINE" "OPTIONS=" all ) ; \
        done
make[1]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src'
for i in lib cmd  ; do \
                ( cd $i ; make -w -- OPTIONS= USRDEFS=-DDEBUG_CMDLINE TESTDEFS= FLAG=-O "FLAG=-O" "TESTDEFS=" "USRDEFS=-DDEBUG_CMDLINE" "OPTIONS=" all ) ; \
        done
make[2]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
g++ -O -I./  -DDEBUG_CMDLINE  -Dunix_style  -c argiter.c
argiter.c: In member function â¬Üvirtual const char* CmdIstreamIter::operator()()â¬":
argiter.c:130: error: no match for â¬Üoperator!â¬" in â¬Ü!((CmdIstreamIter*)this)->CmdIstreamIter::isâ¬"
argiter.c:130: note: candidates are: operator!(bool) <built-in>
argiter.c:135: error: invalid use of undefined type â¬Üstruct istreamâ¬"
cmdline.h:25: error: forward declaration of â¬Üstruct istreamâ¬"
argiter.c:146: error: could not convert â¬Ü((CmdIstreamIter*)this)->CmdIstreamIter::isâ¬" to â¬Üboolâ¬"
make[2]: *** [argiter.o] Error 1
make[2]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
make[2]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/cmd'
( cd ../lib/ ; make -w -- FLAG=-O TESTDEFS= USRDEFS=-DDEBUG_CMDLINE OPTIONS= "FLAG=-O" "TESTDEFS=" "USRDEFS=-DDEBUG_CMDLINE" "OPTIONS=" library ; )
make[3]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
g++ -O -I./  -DDEBUG_CMDLINE  -Dunix_style  -c argiter.c
argiter.c: In member function â¬Üvirtual const char* CmdIstreamIter::operator()()â¬":
argiter.c:130: error: no match for â¬Üoperator!â¬" in â¬Ü!((CmdIstreamIter*)this)->CmdIstreamIter::isâ¬"
argiter.c:130: note: candidates are: operator!(bool) <built-in>
argiter.c:135: error: invalid use of undefined type â¬Üstruct istreamâ¬"
cmdline.h:25: error: forward declaration of â¬Üstruct istreamâ¬"
argiter.c:146: error: could not convert â¬Ü((CmdIstreamIter*)this)->CmdIstreamIter::isâ¬" to â¬Üboolâ¬"
make[3]: *** [argiter.o] Error 1
make[3]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/lib'
make[2]: *** [library] Error 2
make[2]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src/cmd'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/src'
make[1]: Entering directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/doc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/nmittal/RSIGrid/Libraries/CmdLine/CmdLine/doc'
$
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24295270
All stream types (like istream, ostream, etc.) have to be prefixed with std:: now (like std::istream, std::ostream, etc.), as they are in the std namespace.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 24297503
>>>> argiter.c:135: error: invalid use of undefined type â¬Üstruct istreamâ¬"
You probably should rename the argiter.c to argiter.cpp if using iostream classes.
It is not the g++ wouldn't  be able to use the C++ compiler rather the ANSI C compiler on a .c file but you should use the proper file extension if you don't want to confuse others.

Then below

#include <iostream>

you may define

using namespace std;

to not having to use the std:: prefix.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24297531
>> using namespace std;

Dumping a whole namespace into the global namespace is not recommended at all. So, I wouldn't do that, not even for the sake of saving a few keystrokes.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 200 total points
ID: 24298021
>>>> So, I wouldn't do that, not even for the sake of saving a few keystrokes.
It is common practice to do so in the cpp files.

For a .c source ported to .cpp namespace issues must not be expected. On the contrary, if for example a variable named 'string' was used and now doesn't compile, these things should be changed anyhow.

It is not the few keystrokes but the (unnecessary) amount of changes which makes it difficult to find out the real portation issues. I can say that cause I helped to port a 10-million lines of code project from VC6 and RogueWave to VC8 and STL. One of our guidelines was to change as little as possible of the running code in order to be able to use the stored code history of our configuration management system for these major changes nevertheless.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question