Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » ArgcArgv – use argc and argv under Ultimate++!
ArgcArgv – use argc and argv under Ultimate++! [message #3910] Sat, 08 July 2006 21:52 Go to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member

CmdLineArgs - a free model application

If you need to forward the command line arguments your Ultimate++ application is started with to another application or especially a library which you do not control, this can be a problem. The target application or library might expect the command line arguments to be passed in a way complying with the C++ standard. Ultimate++ CommandLine() doesnt meet this expectation in many regards.

So I created ArgcArgv which provides int argc and char* argv[]. These variables behave exactly as the standard requires. ArgcArgv can easily be integrated in any application. CmdLineArgs shows how.

I publish the 2 files ArgcArgv.hpp and ArgcArgv.cpp which provide the solution and the 3 files CmdLineArgs.h, CmdLineArgs.lay, and main.cpp which make up the demo application as well as CmdLineArgs.upp zipped to create a single file - as an attachment to this mail hoping that this will be useful to somebody.

I declare the code, which is thoroughly commented, public domain. Still I would really appreciate if a possible user informed me of errors or any improvements.

Werner

P. S.:

The files have been updated. Please use the new package attached to message #8046.

W.

[Updated on: Mon, 05 February 2007 20:28]

Report message to a moderator

Re: ArgcArgv – use argc and argv under Ultimate++! [message #8044 is a reply to message #3910] Mon, 05 February 2007 19:15 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Thank you for this. I am going to try it out now. I use the TCLAP library for command line parsing.

Edit1: The file won't download. It says its 0 bytes. Please post again or link me to it another way.

Thanks

[Updated on: Mon, 05 February 2007 19:22]

Report message to a moderator

Re: ArgcArgv – use argc and argv under Ultimate++! [message #8046 is a reply to message #8044] Mon, 05 February 2007 20:15 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
captainc wrote on Mon, 05 February 2007 19:15

The file won't download. It says its 0 bytes. Please post again or link me to it another way.



The forum moved some time ago. It is likely that this breaks the link.

On your request I post the package again after having updated the files (which now pay heed to "namespace Upp").

Please note that this package was one of my first misdeeds. Rolling Eyes At that time I was an absolute Ultimate++ beginner. Confused Now I'm still an absolute beginner. Sad So use everything at your own risk.

Werner
Re: ArgcArgv – use argc and argv under Ultimate++! [message #8051 is a reply to message #8046] Mon, 05 February 2007 21:34 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Thank you again.
Re: ArgcArgv Euse argc and argv under Ultimate++! [message #10542 is a reply to message #8046] Sun, 15 July 2007 11:10 Go to previous messageGo to next message
kfeng is currently offline  kfeng
Messages: 18
Registered: July 2007
Location: Tokyo, Japan
Promising Member
Werner wrote on Mon, 05 February 2007 20:15

captainc wrote on Mon, 05 February 2007 19:15

The file won't download. It says its 0 bytes. Please post again or link me to it another way.



The forum moved some time ago. It is likely that this breaks the link.

On your request I post the package again after having updated the files (which now pay heed to "namespace Upp").

Please note that this package was one of my first misdeeds. Rolling Eyes At that time I was an absolute Ultimate++ beginner. Confused Now I'm still an absolute beginner. Sad So use everything at your own risk.

Werner



Hi Werner,

Thanks for writing this up. I've been having problems getting a Unit Test to work with U++ - tried cppUnit and UnitTest++, which were both giving me link headaches and strange Microsoft C++ exceptions at strange memory locations.

I ended up using Fructose (a header-only implementation): http://accu.org/index.php/journals/1326, which unfortunately, required argv/argc. Luckily, your package came to the rescue.

Maybe it should be incorporated into U++ Core or some other package for people who need it! Thanks again.

Regards,
Ken

Re: ArgcArgv Euse argc and argv under Ultimate++! [message #10543 is a reply to message #10542] Sun, 15 July 2007 11:33 Go to previous messageGo to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
Quote:

I've been having problems getting a Unit Test to work with U++ - tried cppUnit and UnitTest++, which were both giving me link headaches and strange Microsoft C++ exceptions at strange memory locations.


Thats strange. I have had no serious problems with UnitTest++ and using it a lot.
No compile problems. No link problems with MSVC.

I have uploaded my Upp UnitTest++ package. Just add it to the package dependencies and include UnitTest.h:
#include <UnitTest/UnitTest.h>


After this somthing like:
TEST (MyFirstTest) {
    CHECK(true);
}

should work without problems.

- Ralf

Updated: Small mistake in the code example.
  • Attachment: UnitTest.zip
    (Size: 90.25KB, Downloaded 496 times)

[Updated on: Sun, 15 July 2007 19:01]

Report message to a moderator

Re: ArgcArgv Euse argc and argv under Ultimate++! [message #10551 is a reply to message #10543] Sun, 15 July 2007 17:50 Go to previous messageGo to next message
kfeng is currently offline  kfeng
Messages: 18
Registered: July 2007
Location: Tokyo, Japan
Promising Member
Zardos wrote on Sun, 15 July 2007 11:33

Quote:

I've been having problems getting a Unit Test to work with U++ - tried cppUnit and UnitTest++, which were both giving me link headaches and strange Microsoft C++ exceptions at strange memory locations.


Thats strange. I have had no serious problems with UnitTest++ and using it a lot.
No compile problems. No link problems with MSVC.

I have uploaded my Upp UnitTest++ package. Just add it to the package dependencies and include UnitTest.h:
#include <UnitTest/UnitTest.h>


After this somthing like:
TEST {
    CHECK(true);
}

should work without problems.

- Ralf



Thanks, Ralf, for posting the package in a U++-friendly form - works great!

Not knowing to how build external libs, I was trying to build the lib under VS2005 rather than using the U++ package facility, and I think I was trying to use the UnitTest++.h header in main(). With your packaging as an example, I will know how to build external libs as U++ packages in the future.

I really appreciate your help!

Regards,
Ken

Re: ArgcArgv – use argc and argv under Ultimate++! [message #10720 is a reply to message #8046] Tue, 24 July 2007 15:01 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Does the ArgcArgv package also work for a console app (using it in CONSOLE_APP_MAIN instead of GUI_APP_MAIN)? Does the atexit() function still work as expected in a console app? I am getting heap leaks in a very simple project and am trying to narrow down why...

[Updated on: Tue, 24 July 2007 15:01]

Report message to a moderator

Re: ArgcArgv – use argc and argv under Ultimate++! [message #11588 is a reply to message #3910] Tue, 18 September 2007 16:49 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Well, I tried your UnitTest package but it didn't work for me (Your package is windows only). After that I forgot about it, and recently I made my own "Ultimatized" package of UnitTest++ sources.
This time it should work both on linux and windows.
But I did hit the original sources much harder than you with changes:
* macro CHECK is colliding with UPP macro CHECK (that's sort of stupid name for macro .. both from UPP and from UnitTest++, it's like asking for trouble)
* moved them firstly into root package directory to allow for simple
#include <UnitTest++/UnitTest++.h>

* renamed files TimeHelpers.cpp to avoid duplicate filenames because it's impossible to compile such package with TheIDE ( no reaction so far in this thread from Mirek about adding "exclude from build WHEN" Sad http://www.ultimatepp.org/forum/index.php?t=msg&th=2712& amp; amp;start=0& )
* compilation of content of those files is conditioned by flagWIN32
* moved the tests of UnitTest++ into separate package, so it looks like how I intent to use UnitTest++ package.

(I did some last minute changes today to make it work on Win32 so I'm not sure if I didn't break linux compilation, I will check @home today evening)

(Mirek please, can you take a look on this please?)
I still have one major problem on windows. The test "CrashingTestsAreReportedAsFailures" (UnitTestTest\TestTest.cpp line 64) is disabled in MINGW, so it "works" ok, but in MSC8 debug it does crash the program and TheIDE reports exception of reading from address 0. So the try {} catch block does not catch this crash. Why? Bad compiler options? U++ is stealing this exception? My windows installation is broken? Any ideas?

Under linux (Kubuntu 6.10, gcc 4.1) it works ok (166 tests passed, so also the one with crash is tested, with MINGW only 165 tests are done).

Back to my changes of UnitTest++ ... should I contact the maintainer of original project and suggest some changes which will make it easier to keep the U++ package up to date with minimal changes? I think the renaming of files is generally a good idea which will make it more portable, but rest is unlikely to happen.

And can this package be included in default U++ distribution? (after it will be maybe a tad more polished?)
http://sourceforge.net/projects/unittest-cpp/
License : MIT License
IMHO they have their own license in file COPYING, check my package, which is IMHO BSD compatible, the only restriction is the original license has to be included along with UnitTest++ package and substantial portions of it.
(argh, I broke it with my UnitTestTest package, I didn't copy the COPYING file there too ... Sad ... sorry, I didn't think about it until now)

[Updated on: Tue, 18 September 2007 16:51]

Report message to a moderator

Re: ArgcArgv – use argc and argv under Ultimate++! [message #11601 is a reply to message #3910] Tue, 18 September 2007 21:29 Go to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Of course I broke it under Linux, I forgot about some experiments in package manager...

Either in file UnitTest++/UnitTest++.upp delete line "options(!WIN32) UNITTEST_POSIX;"
or
go to package manager and remove the !WIN32 compiler option on UnitTest++ package.

I'm sorry for the inconvenience.
Previous Topic: examples\HomeBudget
Next Topic: How to write a dll using Ultimate++?
Goto Forum:
  


Current Time: Wed Jun 12 18:01:22 CEST 2024

Total time taken to generate the page: 0.02409 seconds