dev-cpp-users Mailing List for Dev-C++ (Page 2)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(1) |
2
|
|
3
(1) |
4
(6) |
5
(6) |
6
|
7
(9) |
8
(5) |
9
(2) |
|
10
|
11
(3) |
12
(8) |
13
(20) |
14
(4) |
15
(8) |
16
(7) |
|
17
(7) |
18
|
19
|
20
(3) |
21
(14) |
22
(2) |
23
(5) |
|
24
(2) |
25
(11) |
26
(14) |
27
(3) |
28
(1) |
29
(1) |
30
(4) |
|
From: <Rub...@al...> - 2005-04-25 14:06:03
|
Hello LETCHUMANAN
I think you have made two mistakes:
1.- In structure record, time is defined as char. You must define=20
it as char[ ] or char * for using it as destination in the command strncpy(=
data.time,ctime(timer));
2.- strncpy needs three arguments (char *dest, const *char=20
source,size=5Ft maxlen). The last argument is the number of characters to=20
copy.
Regards.
Ruben Savia
Ingeniero Electr=F3nico
Datacom Services
eBD - eBusiness Division
Alcatel de Argentina S.A.
e-mail : rub...@al...=20
Phone: 5411 4349 - 1111 ext.1001
Fax: 5411 4349 - 1199
Alcanet : 2930-1001
Web site: www.ind.alcatel.com=20
|
|
From: Jamiil Abdullah-A. <jam...@ho...> - 2005-04-25 12:24:17
|
Thanks again Alfred, but I don't think is a problem with the user, but with the IDE itself thus the following BUG REPORT: OS: msw-xp IDE: dev-c++ 4.9.9.2 DESCRIPTION: Please be advised that when trying to compile a GTK-- project and accepting all the default parameters provided by DEV-C++ or otherwise, the following error is produced: Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make clean rm -f obj/main.o obj/MainForm.o obj/Project1_private.res bin/Project1.exe g++.exe -c main.cpp -o obj/main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" `pkg-config --cflags gtkmm-2.4` -fexpensive-optimizations -O3 make.exe: *** [obj/main.o] Error -1073741819 Execution terminated ---------- TIA _________________________________________________________________ Scan and help eliminate destructive viruses from your inbound and outbound e-mail and attachments. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. |
|
From: Michal M. <mi...@mo...> - 2005-04-25 08:16:15
|
James Dent wrote: > Hello, > I have been experimenting with OpenGL in Dev-C++, and although it > otherwise seems to work decently, there is no glaux.h header for the > auxilary functions - although there is a static library for them. Does > anyone know any ways around this? you can download glaux devpak here: http://devpaks.org/show.php?devpak=5 or using WebUpdate (Tools\Check for updates/packages\devpaks.org server\OpenGL group) -- Regards, Michal |
|
From: Alfred P. R. <al...@ya...> - 2005-04-25 05:03:29
|
Hi Letchumanan,
Lets see... My suggestions are:
data.time must be char* or char time[26], as ctime returns a pointer to a block of exactly 26 characters.
If you use time_t timer instead of *timer, then you don't have to malloc it. time_t is just a long integer. Also see time, "The return value is stored in the location given by timer. This parameter may be NULL, in which case the return value is not stored." So you could do strncpy( data.time, ctime( time(NULL) ) ); and loose the variable timer altogether unless you need to save it for some reason.
Don't use time as a variable name as it also is a function name. This is just for clarity rather than for functionality. Instead use time_str or some such descriptive nomenclature.
Have a great week, Letchumanan!
LETCHUMANAN SAMINADAN <arl...@ya...> wrote:
Dear all,
Is it possible for me to copy current time. I have a problem on this.... Can some one please help me. My coding as below:-
char * ctime(const time_t *timer);
struct record {
char pass[10],name[15],ptname[30],ptnum[30],cust,time,utl_1;
float pqty,gweight,nweight,thick,width,pitch,density,raw,fin, //variable used
mtused,in,out,xpqty,lossa,lossb,lost,start,stop,hour,utl;
} data;
void addData () {
time_t *timer;
timer = malloc(sizeof(time_t));
*timer = time(NULL); //return system time
strncpy(data.time,ctime(timer));
printf("DATE/TIME : %s", data.time);
printf("-------------------------------------\n");
}
Thank you,
Letchu.....
Alfred P. Reaud
|
|
From: Alfred P. R. <al...@ya...> - 2005-04-25 04:33:53
|
Hi Jamiil, You're welcome. However, I don't have a clue on Error -1073741819. Hex it would be 0xFFFFFFFFC0000005, with the 0xC0000005 being the key indicator (see last link below). I've never had an error with that type of display, so maybe the developers of Dev-C++ can help? What does `pkg-config --cflags gtkmm-2.4` do? I'm curious as to what the quotes signify. Does that comment out that compiler parameter? As to the directory structure, part of the problem may be that the compiler is expecting the object file in the /bin directory, but the objects are actually in the /tmp/bin directory. I'm getting that from the following: The makefile is in /tmp, "Building Makefile: "C:\tmp\Makefile.win"" The object files are in /tmp/obj, "rm -f obj/main.o obj/MainForm.o bin/Project1.exe" The binary fill will be in /tmp/bin, "rm -f obj/main.o obj/MainForm.o bin/Project1.exe" Therefore there will be nothing in /bin. Don't mind "/" as the other slash mark confuses Yahoo! Mail into thinking you're escaping the next character. As a test, try to keep the sources, objects, and executable in the same folder and see if it works. However there are also other possible culprits, such as a worm virus. I Googled (always try to search the Internet for help!) for "Error -1073741819" and came up with the following pages: Sasser Worm: http://www.d-a-l.com/help/archive/index.php/t-15021.html Foward Declarations: http://lists.gnu.org/archive/html/avr-gcc-list/2004-02/msg00177.html, http://lists.gnu.org/archive/html/avr-gcc-list/2004-02/msg00179.html Microsoft says the actual error is error code 5 (access is denied): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xpehelp/html/xehowusingnetcommandtoidentifywin32errorcodesinfbalogfile.asp Hopefully that helps, Jamiil! Have a great week. Jamiil Abdullah-Alkadir <jam...@ho...> wrote: Thanks Alfred for your prompt response. You were absolutely right; I have now created a 'c:\test\bin' directory and therefore overcome that problem. Since this is "TEST" project I have created it in the 'c:\tmp' directory, or as it is referred to in the MSW world "folder". However, I now get another message saying: Compiler: Default compiler Building Makefile: "C:\tmp\Makefile.win" Executing make clean rm -f obj/main.o obj/MainForm.o bin/Project1.exe g++.exe -c main.cpp -o obj/main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" `pkg-config --cflags gtkmm-2.4` -fexpensive-optimizations -O3 make.exe: *** [obj/main.o] Error -1073741819 Execution terminated --- Please note that in there are no '*.o' files in the 'c:\bin' directory. Again thanks for the help. <snip> Alfred P. Reaud |
|
From: Alfred P. R. <al...@ya...> - 2005-04-25 04:09:37
|
Hi Alexsandro, If you place the numbers into a list then they will sort with the sort member function. #include <list> ... std::list <int> a_list; ... a_list.push_back(integer_number); ... a_list.sort(); Vector also has this capability. You may have to create a predicate function if you are tring to sort on an element of a structure that is in the list delcaration. The links go to the MSDN pages for the given members. Hopefully that helps somewhat! Alexsandro Meireles <mei...@gm...> wrote: Hi, all! Does anyone know any function to order elements? What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from the minimum value to the maximum value. Thanks in advance! -- Alexsandro Meireles Alfred P. Reaud |
|
From: Reid T. <rei...@at...> - 2005-04-25 03:27:44
|
Alexsandro Meireles wrote: > Hi, all! > > Does anyone know any function to order elements? > > What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 > 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from > the minimum value to the maximum value. > > Thanks in advance! > > -- > Alexsandro Meireles http://www.google.com/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&hl=en&q=C%2FC%2B%2B+sort+function&btnG=Google+Search |
|
From: Alexsandro M. <mei...@gm...> - 2005-04-25 02:52:22
|
Hi, all! Does anyone know any function to order elements?=20 What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 545= =20 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from the=20 minimum value to the maximum value. Thanks in advance! --=20 Alexsandro Meireles |
|
From: LETCHUMANAN S. <arl...@ya...> - 2005-04-25 01:04:01
|
Dear all,
Is it possible for me to copy current time. I have a problem on this.... Can some one please help me. My coding as below:-
char * ctime(const time_t *timer);
struct record {
char pass[10],name[15],ptname[30],ptnum[30],cust,time,utl_1;
float pqty,gweight,nweight,thick,width,pitch,density,raw,fin, //variable used
mtused,in,out,xpqty,lossa,lossb,lost,start,stop,hour,utl;
} data;
void addData () {
time_t *timer;
timer = malloc(sizeof(time_t));
*timer = time(NULL); //return system time
strncpy(data.time,ctime(timer));
printf("DATE/TIME : %s", data.time);
printf("-------------------------------------\n");
}
Thank you,
Letchu.....
Yahoo! Mobile
- Download the latest ringtones, games, and more! |
|
From: James D. <sem...@ho...> - 2005-04-24 22:56:35
|
Hello, I have been experimenting with OpenGL in Dev-C++, and although it otherwise seems to work decently, there is no glaux.h header for the auxilary functions - although there is a static library for them. Does anyone know any ways around this? Thanks. - Sam _________________________________________________________________ Need more speed? Get Xtra Broadband @ http://jetstream.xtra.co.nz/chm/0,,202853-1000,00.html |
|
From: Jamiil Abdullah-A. <jam...@ho...> - 2005-04-24 06:29:46
|
Thanks Alfred for your prompt response. You were absolutely right; I have now created a 'c:\test\bin' directory and therefore overcome that problem. Since this is "TEST" project I have created it in the 'c:\tmp' directory, or as it is referred to in the MSW world "folder". However, I now get another message saying: Compiler: Default compiler Building Makefile: "C:\tmp\Makefile.win" Executing make clean rm -f obj/main.o obj/MainForm.o bin/Project1.exe g++.exe -c main.cpp -o obj/main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" `pkg-config --cflags gtkmm-2.4` -fexpensive-optimizations -O3 make.exe: *** [obj/main.o] Error -1073741819 Execution terminated --- Please note that in there are no '*.o' files in the 'c:\bin' directory. Again thanks for the help. >From: "Alfred P. Reaud" <al...@ya...> >To: Dev-Cpp UserList <dev...@li...> >Subject: Re: [Dev-C++] GTK-- and DEV-C++ settings >Date: Sat, 23 Apr 2005 10:21:44 -0700 (PDT) > >Hi Jamiil, > >You may try to check you project parameters, specifically the output folder >configuration, as this sounds like a make file issue. Usually the >executable will be created in the same folder as the sources, and "bin" may >not exist. Also, GTK may be setup or configured for Linux/Unix and >therefore the folder naming style is incompatible with Windows. > >Hopefully that helps. Have a great weekend! > >Jamiil Abdullah-Alkadir <jam...@ho...> wrote: >Hello Deveys!! >I dont know if this has been a questions that has been asked way too many >times, but I am really new in the DevC++ and the MSW worlds, so please take >it easy on me if this is one of those questions classified as DUMB. >Using DevC++ I have created a new project using GUI->GTK--, however, when I >try to compile the program I get an error message saying: could not create >executable output directory: bin. Please check your settings. > >What can I do to solve this problem? > >TIA ><snip> > > > > > >Alfred P. Reaud > > _________________________________________________________________ Scan and help eliminate destructive viruses from your inbound and outbound e-mail and attachments. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. |
|
From: Alfred P. R. <al...@ya...> - 2005-04-23 17:21:53
|
Hi Jamiil, You may try to check you project parameters, specifically the output folder configuration, as this sounds like a make file issue. Usually the executable will be created in the same folder as the sources, and "bin" may not exist. Also, GTK may be setup or configured for Linux/Unix and therefore the folder naming style is incompatible with Windows. Hopefully that helps. Have a great weekend! Jamiil Abdullah-Alkadir <jam...@ho...> wrote: Hello Deveys!! I dont know if this has been a questions that has been asked way too many times, but I am really new in the DevC++ and the MSW worlds, so please take it easy on me if this is one of those questions classified as DUMB. Using DevC++ I have created a new project using GUI->GTK--, however, when I try to compile the program I get an error message saying: could not create executable output directory: bin. Please check your settings. What can I do to solve this problem? TIA <snip> Alfred P. Reaud |
|
From: Jamiil Abdullah-A. <jam...@ho...> - 2005-04-23 15:15:39
|
Hello Deveys!! I dont know if this has been a questions that has been asked way too many times, but I am really new in the DevC++ and the MSW worlds, so please take it easy on me if this is one of those questions classified as DUMB. Using DevC++ I have created a new project using GUI->GTK--, however, when I try to compile the program I get an error message saying: could not create executable output directory: bin. Please check your settings. What can I do to solve this problem? TIA _________________________________________________________________ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. |
|
From: Alfred P. R. <al...@ya...> - 2005-04-23 02:20:59
|
Apologies, the variable onepass became onfiltered during spell checking in my copy, so I'm expecting that it did in yours too!
"Alfred P. Reaud" <al...@ya...> wrote:<snip>
bool onepass = false;
system("CLS");
cout << "Student Pack \t\t\t\t\t\t\t\t v1.0" << endl << endl;
cout << "Please Make A Selection " << endl;
cout << "------------------------" << endl;
cout << "(M)oney Counter" << endl << endl;
cout << "(T)emperature Converter" << endl << endl;
cout << "(C)alculator" << endl << endl;
cout << "C(r)edits" << endl << endl;
cout << "(B)ug Reporting" << endl << endl;
cout << "(E)xit" << endl << endl;
do {
cin >> menuSelection;
// It may be better to use getche if menuSelection is an int.
// menuSelection = getche();
if ( (menuSelection == 'm') || (menuSelection == 't') || (menuSelection == 'c') || (menuSelection == 'r') || (menuSelection == 'b') || (menuSelection == 'e') ) {
menuSelection = (menuSelection - 32);
break;
}
else {
// To only do one pass here add the boolean flag as follows
if (!onepass) {
cout << "Please make a proper slection. " << endl;
onepass = true;
}
}
} while ( true );
<snip>
Alfred P. Reaud
|
|
From: Alfred P. R. <al...@ya...> - 2005-04-23 02:11:08
|
Hi Ryan,
If I understand correctly, you only want to output the error prompt once? It looks like it's written to prompt you every time a wrong character is pressed. One suggestion would be to place a boolean flag in it. Another would be to put the whole section from Menu: to the end of the if statement in a while or do loop until it exits with the proper selection.
Not knowing what menuSelection is cast as, one has to assume char, as that is the default istream element. So at the else you set a flag, test for it (why? it will always be true!), prompt, and then get a character. Then you loop with the goto MENU. Goto's that resolve to a location outside of a loop are bad form, IMHO.
Try this:
bool onepass = false;
system("CLS");
cout << "Student Pack \t\t\t\t\t\t\t\t v1.0" << endl << endl;
cout << "Please Make A Selection " << endl;
cout << "------------------------" << endl;
cout << "(M)oney Counter" << endl << endl;
cout << "(T)emperature Converter" << endl << endl;
cout << "(C)alculator" << endl << endl;
cout << "C(r)edits" << endl << endl;
cout << "(B)ug Reporting" << endl << endl;
cout << "(E)xit" << endl << endl;
do {
cin >> menuSelection;
// It may be better to use getche if menuSelection is an int.
// menuSelection = getche();
if ( (menuSelection == 'm') || (menuSelection == 't') || (menuSelection == 'c') || (menuSelection == 'r') || (menuSelection == 'b') || (menuSelection == 'e') ) {
menuSelection = (menuSelection - 32);
break;
}
else {
// To only do one pass here add the boolean flag as follows
if (!onepass) {
cout << "Please make a proper slection. " << endl;
onepass = true;
}
}
} while ( true );
Hope that helped!
Ryan Turney <sk8...@gm...> wrote:
Hello,
I am writing a small program that has many different options in it and
when you start it, it will show you a menu. But the problem is that
you can only push in a few letters to use the menu and if you put a
wrong one it will say please select a better option. But if you type
in more than one wrong character it will run the error catching lines
again. How do I get this to run once even if there are 6 wrong
characters inputted? The error catching code I have now look like:
int main(int nNumberofArgs, char* pszArgs[])
{
Error = 0;
MENU:
cout << "Student Pack \t\t\t\t\t\t\t\t v1.0" << endl << endl;
cout << "Please Make A Selection " << endl;
cout << "------------------------" << endl;
cout << "(M)oney Counter" << endl << endl;
cout << "(T)emperature Converter" << endl << endl;
cout << "(C)alculator" << endl << endl;
cout << "C(r)edits" << endl << endl;
cout << "(B)ug Reporting" << endl << endl;
cout << "(E)xit" << endl << endl;
cin >> menuSelection;
if ((menuSelection == 'm') || (menuSelection == 't') || (menuSelection
== 'c') || (menuSelection == 'r') || (menuSelection == 'b') ||
(menuSelection == 'e'))
{
menuSelection = (menuSelection - 32);
}
else
{
Error = Error + 1;
system("CLS");
while (Error == 1)
{
Error = Error - 1;
cout << "Please make a proper slection. " << endl;
getch();
system("CLS");
goto MENU;
}
}
Notice: This is not even close to all the coding but this is where the
problem is taking place.
Please help me if you can.
Thank you.
--
-Ryan
Alfred P. Reaud
|
|
From: Ryan T. <sk8...@gm...> - 2005-04-23 01:14:22
|
Hello,
I am writing a small program that has many different options in it and
when you start it, it will show you a menu. But the problem is that
you can only push in a few letters to use the menu and if you put a
wrong one it will say please select a better option. But if you type
in more than one wrong character it will run the error catching lines
again. How do I get this to run once even if there are 6 wrong
characters inputted? The error catching code I have now look like:
int main(int nNumberofArgs, char* pszArgs[])
{
Error =3D 0;
MENU:
cout << "Student Pack \t\t\t\t\t\t\t\t v1.0" << endl << endl;
cout << "Please Make A Selection " << endl;
cout << "------------------------" << endl;
cout << "(M)oney Counter" << endl << endl;
cout << "(T)emperature Converter" << endl << endl;
cout << "(C)alculator" << endl << endl;
cout << "C(r)edits" << endl << endl;
cout << "(B)ug Reporting" << endl << endl;
cout << "(E)xit" << endl << endl;
cin >> menuSelection;
if ((menuSelection =3D=3D 'm') || (menuSelection =3D=3D 't') || (menuSelect=
ion
=3D=3D 'c') || (menuSelection =3D=3D 'r') || (menuSelection =3D=3D 'b') ||
(menuSelection =3D=3D 'e'))
{
menuSelection =3D (menuSelection - 32);
}
else
{
Error =3D Error + 1;
system("CLS");
while (Error =3D=3D 1)
{
Error =3D Error - 1;
cout << "Please make a proper slection. " << endl;
getch();
system("CLS");
goto MENU;
} =20
=20
}
Notice: This is not even close to all the coding but this is where the
problem is taking place.
Please help me if you can.
Thank you.
--=20
-Ryan
|
|
From: jose i. c. <ji...@gm...> - 2005-04-22 21:07:17
|
Greetings! I am in search of older emails sent to this list. Is there a place where sourceforge.net keeps a searchable site for this list emails_ thanks, jos=E9 |
|
From: Alfred P. R. <al...@ya...> - 2005-04-22 00:00:40
|
Hi Celsius, The best way is to do it via the Check for Updates... tool in the menu bar. I don't have Dev-C++ installed right now, but the command is in the same menu as Options. Both the source and the binaries only (for Windows) are available as a package. Otherwise download the source at http://sources.redhat.com/insight/ celsius thomas <atc...@ya...> wrote: Hi folks, will any one give information on, where to download insight debugger i am running win 98 machine,compiler is Bloodshed Dev-C++ ,version 4 mingw compiler 2.95.2-1 Send instant messages to your online friends http://uk.messenger.yahoo.com Alfred P. Reaud |
|
From: Francesco <xtr...@vi...> - 2005-04-21 20:48:13
|
Thanks to everybody for the in-depth explanations.
Francesco
On Apr 21, 2005, at 7:04 PM, Mat...@Ve... wrote:
> Alright. Once you have overloaded an operator, you are stuck with that
> operator. However, overloaded operators apply on a class by class
> basis. The
> HugeStuff type will not use the operator= that you defined for your
> class.
> Can you think of a way to refactor your operator= to operate in terms
> of the
> default operator= define for type HugeStuff?
>
> Also, memcpy should be very fast. If it's not, try rolling your own. It
> might work something like the below code. Also make sure you enable -O3
> -fexpensive-optimizations when you build the code. You might also need
> -mcpu
> and -mtune.
>
> Some routines benefit heavily from optimization. Copy-heavy routines
> seem to
> need help with this. When I wrote a crypto algorithm a while ago, it
> doubled
> the speed to optimize it fully.
>
> void copy(void* begin, void* end, void* dest)
> {
> for((char*) i=0; i<(char*)end; i++)
> {
> *(char*)dest=(char*)(begin+i);
> }
> }
>
> HTH!
> Matt
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of
> Francesco
> Sent: Thursday, April 21, 2005 3:02 AM
> To: Alfred P. Reaud
> Cc: Dev C++
> Subject: Re: [Dev-C++] Shallow copy
>
>
> Thanks for answering Alfred,
> I'm already using the STL but since I'm still in a learning stage I was
> trying to understand the "inner workings". Suppose I'm building ( just
> for
> my own pleasure :-) ) a simple competitor to the vector template. Or
> to make
> it even more banal, suppose I have the following code:
>
>
> class MyData
> {
> typeHugeStuff * mHugeStuffPtr;
> // ....
> public:
> // ....
> MyData const & operator=( MyData const & inMyData ); // the
> definition of this copies also the stuff pointed to by mHugeStuffPtr
> // .....
> };
>
>
> template< typename T >
> void MySwap( T * inDataPtr1, T * inDataPtr2 )
> {
> #ifdef BAD_SWAP
> // the following will swap in memory the two objects but will
> also
> deallocate/allocate/copy hugeStuff
> T tempData;
>
>
> tempData = *inDataPtr1;
> *inDataPtr1 = *inDataPtr2;
> *inDataPtr2 = tempData;
> #else
> // the following will just swap bitwise the members of the two
> objects without erasing/duplicating/whatever hugeStuff
> // but this bitwise copy seems to be slower than using the
> operator=
> (when it's not overloaded)
> // so I was wondering if it is possible to access the
> UNoverloaded
> operator= in objects that have overloaded it....
> char * aPtr;
>
>
> aPtr = (char*) malloc ( sizeof( T ) );
> memcpy( aPtr, inDataPtr1, sizeof( T ) );
> memcpy( inDataPtr1, inDataPtr2, sizeof( T ) );
> memcpy( inDataPtr2, aPtr, sizeof( T ) );
> free( aPtr );
> #endif
> }
>
>
> void main( void )
> {
> MyData * aDataPtr;
>
> aDataPtr = new MyData[ 100 ];
> FillUp( aDataPtr, 100 ); // filling up with data
> MySwap< MyData >( aDataPtr + 20, aDataPtr + 40 ); // just
> because.... :-)
> }
>
>
> Thanks in advance for any insight,
> Francesco
>
>
> On Apr 20, 2005, at 7:46 PM, Alfred P. Reaud wrote:
>
>
> Hi Francesco,
>
> Your array of class objects would be better served if it where a list
> or
> vector of class objects instead of an array. Then you can use the
> iterator
> features, including list and vector specific swap and sort member
> functions.
> I f you must use an array of class objects, then there's always the
> <algorithm> standard template library header. Algorithm has a rich
> set of
> functions that include swap, sort, and other useful data manipulation
> algorithms such as unique, etc. These functions are usually
> optimized, and
> work in most instances significantly better than manually coded swap
> or sort
> functions.
>
> I'm not actually sure what you mean by "deep copy", however, I'm
> assuming
> that you mean actual data copying. You shouldn't be copying data to
> swap
> it! You should be swapping pointers to the data. Maybe the issue is
> in
> using a class class_objects[array_size]; declaration vs. a class
> *class_objects; declaration, because the overloaded operator= may
> operate in
> a different fashion between a pointer and an array element (i.e.
> class_objects[7], is a pointer, but in machine code is actually a set
> of
> pointer arithmetic operations). The class operator= should already be
> configured to correctly do something like:
>
> class *obj_a, *obj_b, *temp;
> obj_a = new class; ...;
> temp = obj_a; obj_a = obj_b; obj_b = temp;
> delete(temp); ...
>
> so that should work correctly, ***** however *****
>
>
>
> list<class> obj_list;
> list<class>::iterator obj_iter;
> obj_list.push_back(obj_a); ...
> obj_iter = obj_list.begin();
> obj_list.sort() or obj_list.sort( compare_function );
> ...
>
> is easier, more elegant, and uses the optimized features of C++!
> Hopefully
> the above helps!
>
>
> Francesco <xtr...@vi...> wrote:
> Hi everybody,
> I'm a total beginner and I have the following problem:
> I have an array of objects instantiated from a class that has member
> pointers to dynamically allocated data. This class has also the usual
> overloaded operator=. I have to sort this array and I need to do some
> swapping. But swapping by "deep copy" seems useless to me in this case,
> thus is it possible somehow to override the overloaded operator= and
> use just for the swapping the normal operator =? I could use memcpy for
> a bitwise copy, but it seems to be significantly slower, especially
> for small objects.
> Thanks in advance,
> Francesco
> <snip>
>
>
>
>
> Alfred P. Reaud
> <image.tiff>
> ___________________________________________________________________
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure. If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof. Thank you.
>
|
|
From: Robert A. <ral...@gm...> - 2005-04-21 20:06:31
|
Actually, I believe that the ANSI standard allows main to just end without any return code which isn't allowed for any other function declared to return an int. And as a special consideration for main it will return '0' (zero) for you. Actually.. a few web searches indicate that is C++ standard not C. So it looks like for C you are correct... what ever garbage happens to be in the return register. -Robert On 4/21/05, Ray Kulhanek <kul...@wr...> wrote: > Another thing to consider is that, as far as I know, while the return > *type* of a function defaults to int, the return *value* doesn't default > to anything in particular. If so, it might just return whatever value > happens to live in memory at a certain point, and if the value is > anything other than 0, the operating system will interpret that to mean > that the program terminated with an error. (It's good form to > include the type specification and return statement, regardless.) >=20 > Per Westermark <pw...@ia...> wrote: > > Note that > > main() > > is ONLY allowed for C programs, where a symbol without a declared data > > type defaults to int, i.e. > > main() > > in reality means: > > int main() > > in a C program. > > For C++ programs, you MUST actually use > > int main() > > since the ISO C++ standard requires it. Yes, I know that g++ do accept > > the > > lazy form and only emits "warning: ISO C++ forbids declaration of > > `main=3DB4 > > with no type" if warnings are enabled. However, don't assume something > > about how other compilers look at ISO compliance requirements! > > /Per W > > On Thu, 21 Apr 2005, Austin Scholze wrote: > > > >> also, I have found in dev-C++ that you may just use > >> > >> main() > >> > >> without actually initializing it and that it will exit at the end of > >> the function. > >> ----- Original Message ----- > >> From: Verne H. Bohlender > >> To: Dev C++ ; Alfred P. Reaud > >> Sent: Wednesday, April 20, 2005 9:48 PM > >> Subject: Re: [Dev-C++] Error using void main (void) > >> > >> > >> That's what it should say as it really should be > >> > >> int main() or with all the other goodies inside the brackets. If yo= u > >> read across it says"int main void for the two ( )'s for the void here! > >> > >> Verne > >> The GRIN Genius who knows nothing! > >> > >> Warnings are mostly ignorable, or nice if you like to write clean > >> portable code. main should always return an int as that's the exit > >> value that the executable gives to DOS/Win/Linux upon completion. > >> Source should compile and run with a void main. However, main's exit > >> value will then always be 0 and therefore useless to test for a certai= n > >> execution completion status. > >> > >> Alexsandro Meireles <mei...@gm...> wrote: > >> Hi, all! > >> > >> I tried to use the following expression in Dev-C++ > >> > >> void main (void) > >> > >> The compiler give a warning message "output of main is not int". > >> Something like that. Although it gives this warning it compilies well. > >> Why this happens? Main should always have a return type? > >> > >> Tks in advance! > >> > >> -- > >> Alexsandro Meireles > >> > >> > >> > >> Alfred P. Reaud >=20 > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Andrew M. <aj...@ta...> - 2005-04-21 20:03:59
|
I've recently started using Dev-C++, and generally, I've been quite impressed with the functionality and configurability available. I wondered, however, if it has ever been suggested that in-built support for SVN (Subversion) be added ? As far as I can see, this would require very little modification over and above the CVS support that's already there : indeed, if it were possible to totally configure the options passed to CVS (for instance, to be able to remove the -z compression parameter), then I think the CVS support as it stands would work with SVN - it'd just be a case of 'pointing' the CVS executable option to svn.exe, since SVN and CVS share many of the same directives : checkout, update, diff and so on. Cheers, Andy MacLennan. PS. Apologies if this has already been discussed on this mailing list, but a cursory search for 'SVN' and 'Subversion' didn't reveal anything ... |
|
From: celsius t. <atc...@ya...> - 2005-04-21 19:21:29
|
Hi folks,
will any one give information on, where to download insight debugger
i am running win 98 machine,compiler is Bloodshed Dev-C++ ,version 4
mingw compiler 2.95.2-1
Send instant messages to your online friends http://uk.messenger.yahoo.com |
|
From: <Mat...@Ve...> - 2005-04-21 18:53:22
|
Per,
You spent a _lot_ longer on that than I ever would have. :-) I was just
giving a quick general answer since I'm at work and in kind of a hurry to
finish up a big project. Yours was a really cool explanation. Thanks for
writing it. It taught me a lot about how memcpy really works.
I suppose that-- this observation is for the truly pedantic, you could seek
out its "official" implementations in the GLIBC source code. Don't you just
love the GPL? :-)
Regards,
Matt
-----Original Message-----
From: Per Westermark [mailto:pw...@ia...]
Sent: Thursday, April 21, 2005 11:01 AM
To: Mat...@Ve...
Cc: xtr...@vi...; al...@ya...;
dev...@li...
Subject: RE: [Dev-C++] Shallow copy
For small objects, an inlined copy function might be better, but for
larger blocks, the memcpy() function is optimized to switch over to 32-bit
(or larger) moves for maximum performance, i.e. it definitely wins over a
char* copy.
By the way, a couple of problems with the code:
No (char*)i - you wan't to declare i as a variable, not typecast it to
char*.
Second, avoid extra variables. Your code is using 4 variables. Instead of
creating a new variable i and do begin+i you should increment begin.
Besides using a variable less, it also optimizes the memory reference for
some processors.
A low-end memcpy() looks something like:
void* copy(void *dst,void *src,unsigned size) {
char* orig_dst = dst;
char* end = (char*)src + size;
while ((char*)src < end) {
*((char*)dst)++ = *((char*)src)++;
}
return orig_dst;
}
A normal memcpy() will do some optional single byte copies at start to get
word-aligned, and then do several unrolled word-copies (as large word as
possible, i.e. normally 32 or 64 bit) and then end with some optional
single-byte copies again.
If data is known to always be well-aligned and of a reasonable size, a
better code would be (pseudo-code):
void* copy(void *dst,void *src,unsigned size) {
// Observe: Code assumes that src and dst are aligned to sizeof(long)
// If they are not, one or more single-byte copy are needed...
void* orig_dst = dst;
unsigned r = size % sizeof(unsigned long);
unsigned count = size / sizeof(unsigned long);
if (size >= 4) {
// Unroll loop 4 times.
size >>= 2;
r += 4*sizeof(unsigned long);
} else {
// Too small block to unroll.
r += 4*size;
size = 0;
}
for (;size; size--) {
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
}
// r and this code not needed if size is a multiple of sizeof(long)
for (;r; r--) {
*((char*)dst)++ = *((char*)src)++;
}
return *orig_dst;
}
In reality, this kind of code is written in assembler, to allow further
optimizations by for example using calculated jumps into the unrolling
code. Also, some processors have special instructions for memory transfer
operations.
/Per W
On Thu, 21 Apr 2005 Mat...@Ve... wrote:
> Alright. Once you have overloaded an operator, you are stuck with that
> operator. However, overloaded operators apply on a class by class basis.
The
> HugeStuff type will not use the operator= that you defined for your class.
> Can you think of a way to refactor your operator= to operate in terms of
the
> default operator= define for type HugeStuff?
>
> Also, memcpy should be very fast. If it's not, try rolling your own. It
> might work something like the below code. Also make sure you enable -O3
> -fexpensive-optimizations when you build the code. You might also need
-mcpu
> and -mtune.
>
> Some routines benefit heavily from optimization. Copy-heavy routines seem
to
> need help with this. When I wrote a crypto algorithm a while ago, it
doubled
> the speed to optimize it fully.
>
> void copy(void* begin, void* end, void* dest)
> {
> for((char*) i=0; i<(char*)end; i++)
> {
> *(char*)dest=(char*)(begin+i);
> }
> }
>
> HTH!
> Matt
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Francesco
> Sent: Thursday, April 21, 2005 3:02 AM
> To: Alfred P. Reaud
> Cc: Dev C++
> Subject: Re: [Dev-C++] Shallow copy
>
>
> Thanks for answering Alfred,
> I'm already using the STL but since I'm still in a learning stage I was
> trying to understand the "inner workings". Suppose I'm building ( just for
> my own pleasure :-) ) a simple competitor to the vector template. Or to
make
> it even more banal, suppose I have the following code:
>
>
> class MyData
> {
> typeHugeStuff * mHugeStuffPtr;
> // ....
> public:
> // ....
> MyData const & operator=( MyData const & inMyData ); // the
> definition of this copies also the stuff pointed to by mHugeStuffPtr
> // .....
> };
>
>
> template< typename T >
> void MySwap( T * inDataPtr1, T * inDataPtr2 )
> {
> #ifdef BAD_SWAP
> // the following will swap in memory the two objects but will also
> deallocate/allocate/copy hugeStuff
> T tempData;
>
>
> tempData = *inDataPtr1;
> *inDataPtr1 = *inDataPtr2;
> *inDataPtr2 = tempData;
> #else
> // the following will just swap bitwise the members of the two
> objects without erasing/duplicating/whatever hugeStuff
> // but this bitwise copy seems to be slower than using the
operator=
> (when it's not overloaded)
> // so I was wondering if it is possible to access the UNoverloaded
> operator= in objects that have overloaded it....
> char * aPtr;
>
>
> aPtr = (char*) malloc ( sizeof( T ) );
> memcpy( aPtr, inDataPtr1, sizeof( T ) );
> memcpy( inDataPtr1, inDataPtr2, sizeof( T ) );
> memcpy( inDataPtr2, aPtr, sizeof( T ) );
> free( aPtr );
> #endif
> }
>
>
> void main( void )
> {
> MyData * aDataPtr;
>
> aDataPtr = new MyData[ 100 ];
> FillUp( aDataPtr, 100 ); // filling up with data
> MySwap< MyData >( aDataPtr + 20, aDataPtr + 40 ); // just
> because.... :-)
> }
>
>
> Thanks in advance for any insight,
> Francesco
>
>
> On Apr 20, 2005, at 7:46 PM, Alfred P. Reaud wrote:
>
>
> Hi Francesco,
>
> Your array of class objects would be better served if it where a list or
> vector of class objects instead of an array. Then you can use the
iterator
> features, including list and vector specific swap and sort member
functions.
> I f you must use an array of class objects, then there's always the
> <algorithm> standard template library header. Algorithm has a rich set of
> functions that include swap, sort, and other useful data manipulation
> algorithms such as unique, etc. These functions are usually optimized,
and
> work in most instances significantly better than manually coded swap or
sort
> functions.
>
> I'm not actually sure what you mean by "deep copy", however, I'm assuming
> that you mean actual data copying. You shouldn't be copying data to swap
> it! You should be swapping pointers to the data. Maybe the issue is in
> using a class class_objects[array_size]; declaration vs. a class
> *class_objects; declaration, because the overloaded operator= may operate
in
> a different fashion between a pointer and an array element (i.e.
> class_objects[7], is a pointer, but in machine code is actually a set of
> pointer arithmetic operations). The class operator= should already be
> configured to correctly do something like:
>
> class *obj_a, *obj_b, *temp;
> obj_a = new class; ...;
> temp = obj_a; obj_a = obj_b; obj_b = temp;
> delete(temp); ...
>
> so that should work correctly, ***** however *****
>
>
>
> list<class> obj_list;
> list<class>::iterator obj_iter;
> obj_list.push_back(obj_a); ...
> obj_iter = obj_list.begin();
> obj_list.sort() or obj_list.sort( compare_function );
> ...
>
> is easier, more elegant, and uses the optimized features of C++!
Hopefully
> the above helps!
>
>
> Francesco <xtr...@vi...> wrote:
> Hi everybody,
> I'm a total beginner and I have the following problem:
> I have an array of objects instantiated from a class that has member
> pointers to dynamically allocated data. This class has also the usual
> overloaded operator=. I have to sort this array and I need to do some
> swapping. But swapping by "deep copy" seems useless to me in this case,
> thus is it possible somehow to override the overloaded operator= and
> use just for the swapping the normal operator =? I could use memcpy for
> a bitwise copy, but it seems to be significantly slower, especially
> for small objects.
> Thanks in advance,
> Francesco
> <snip>
>
>
>
>
> Alfred P. Reaud
> <image.tiff>
> ___________________________________________________________________
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure. If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof. Thank you.
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ray K. <kul...@wr...> - 2005-04-21 18:20:35
|
Another thing to consider is that, as far as I know, while the return *type* of a function defaults to int, the return *value* doesn't default to anything in particular. If so, it might just return whatever value happens to live in memory at a certain point, and if the value is anything other than 0, the operating system will interpret that to mean that the program terminated with an error. (It's good form to include the type specification and return statement, regardless.) Per Westermark <pw...@ia...> wrote: > Note that > main() > is ONLY allowed for C programs, where a symbol without a declared data > type defaults to int, i.e. > main() > in reality means: > int main() > in a C program. > For C++ programs, you MUST actually use > int main() > since the ISO C++ standard requires it. Yes, I know that g++ do accept > the > lazy form and only emits "warning: ISO C++ forbids declaration of > `main=B4 > with no type" if warnings are enabled. However, don't assume something > about how other compilers look at ISO compliance requirements! > /Per W > On Thu, 21 Apr 2005, Austin Scholze wrote: > >> also, I have found in dev-C++ that you may just use >> >> main() >> >> without actually initializing it and that it will exit at the end of >> the function. >> ----- Original Message ----- >> From: Verne H. Bohlender >> To: Dev C++ ; Alfred P. Reaud >> Sent: Wednesday, April 20, 2005 9:48 PM >> Subject: Re: [Dev-C++] Error using void main (void) >> >> >> That's what it should say as it really should be >> >> int main() or with all the other goodies inside the brackets. If you >> read across it says"int main void for the two ( )'s for the void here! >> >> Verne >> The GRIN Genius who knows nothing! >> >> Warnings are mostly ignorable, or nice if you like to write clean >> portable code. main should always return an int as that's the exit >> value that the executable gives to DOS/Win/Linux upon completion. >> Source should compile and run with a void main. However, main's exit >> value will then always be 0 and therefore useless to test for a certain >> execution completion status. >> >> Alexsandro Meireles <mei...@gm...> wrote: >> Hi, all! >> >> I tried to use the following expression in Dev-C++ >> >> void main (void) >> >> The compiler give a warning message "output of main is not int". >> Something like that. Although it gives this warning it compilies well. >> Why this happens? Main should always have a return type? >> >> Tks in advance! >> >> -- >> Alexsandro Meireles >> >> >> >> Alfred P. Reaud |
|
From: Per W. <pw...@ia...> - 2005-04-21 18:01:19
|
For small objects, an inlined copy function might be better, but for
larger blocks, the memcpy() function is optimized to switch over to 32-bit
(or larger) moves for maximum performance, i.e. it definitely wins over a
char* copy.
By the way, a couple of problems with the code:
No (char*)i - you wan't to declare i as a variable, not typecast it to
char*.
Second, avoid extra variables. Your code is using 4 variables. Instead of
creating a new variable i and do begin+i you should increment begin.
Besides using a variable less, it also optimizes the memory reference for
some processors.
A low-end memcpy() looks something like:
void* copy(void *dst,void *src,unsigned size) {
char* orig_dst = dst;
char* end = (char*)src + size;
while ((char*)src < end) {
*((char*)dst)++ = *((char*)src)++;
}
return orig_dst;
}
A normal memcpy() will do some optional single byte copies at start to get
word-aligned, and then do several unrolled word-copies (as large word as
possible, i.e. normally 32 or 64 bit) and then end with some optional
single-byte copies again.
If data is known to always be well-aligned and of a reasonable size, a
better code would be (pseudo-code):
void* copy(void *dst,void *src,unsigned size) {
// Observe: Code assumes that src and dst are aligned to sizeof(long)
// If they are not, one or more single-byte copy are needed...
void* orig_dst = dst;
unsigned r = size % sizeof(unsigned long);
unsigned count = size / sizeof(unsigned long);
if (size >= 4) {
// Unroll loop 4 times.
size >>= 2;
r += 4*sizeof(unsigned long);
} else {
// Too small block to unroll.
r += 4*size;
size = 0;
}
for (;size; size--) {
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
*((unsigned long*)dst)++ = *((unsigned long*)src)++;
}
// r and this code not needed if size is a multiple of sizeof(long)
for (;r; r--) {
*((char*)dst)++ = *((char*)src)++;
}
return *orig_dst;
}
In reality, this kind of code is written in assembler, to allow further
optimizations by for example using calculated jumps into the unrolling
code. Also, some processors have special instructions for memory transfer
operations.
/Per W
On Thu, 21 Apr 2005 Mat...@Ve... wrote:
> Alright. Once you have overloaded an operator, you are stuck with that
> operator. However, overloaded operators apply on a class by class basis. The
> HugeStuff type will not use the operator= that you defined for your class.
> Can you think of a way to refactor your operator= to operate in terms of the
> default operator= define for type HugeStuff?
>
> Also, memcpy should be very fast. If it's not, try rolling your own. It
> might work something like the below code. Also make sure you enable -O3
> -fexpensive-optimizations when you build the code. You might also need -mcpu
> and -mtune.
>
> Some routines benefit heavily from optimization. Copy-heavy routines seem to
> need help with this. When I wrote a crypto algorithm a while ago, it doubled
> the speed to optimize it fully.
>
> void copy(void* begin, void* end, void* dest)
> {
> for((char*) i=0; i<(char*)end; i++)
> {
> *(char*)dest=(char*)(begin+i);
> }
> }
>
> HTH!
> Matt
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Francesco
> Sent: Thursday, April 21, 2005 3:02 AM
> To: Alfred P. Reaud
> Cc: Dev C++
> Subject: Re: [Dev-C++] Shallow copy
>
>
> Thanks for answering Alfred,
> I'm already using the STL but since I'm still in a learning stage I was
> trying to understand the "inner workings". Suppose I'm building ( just for
> my own pleasure :-) ) a simple competitor to the vector template. Or to make
> it even more banal, suppose I have the following code:
>
>
> class MyData
> {
> typeHugeStuff * mHugeStuffPtr;
> // ....
> public:
> // ....
> MyData const & operator=( MyData const & inMyData ); // the
> definition of this copies also the stuff pointed to by mHugeStuffPtr
> // .....
> };
>
>
> template< typename T >
> void MySwap( T * inDataPtr1, T * inDataPtr2 )
> {
> #ifdef BAD_SWAP
> // the following will swap in memory the two objects but will also
> deallocate/allocate/copy hugeStuff
> T tempData;
>
>
> tempData = *inDataPtr1;
> *inDataPtr1 = *inDataPtr2;
> *inDataPtr2 = tempData;
> #else
> // the following will just swap bitwise the members of the two
> objects without erasing/duplicating/whatever hugeStuff
> // but this bitwise copy seems to be slower than using the operator=
> (when it's not overloaded)
> // so I was wondering if it is possible to access the UNoverloaded
> operator= in objects that have overloaded it....
> char * aPtr;
>
>
> aPtr = (char*) malloc ( sizeof( T ) );
> memcpy( aPtr, inDataPtr1, sizeof( T ) );
> memcpy( inDataPtr1, inDataPtr2, sizeof( T ) );
> memcpy( inDataPtr2, aPtr, sizeof( T ) );
> free( aPtr );
> #endif
> }
>
>
> void main( void )
> {
> MyData * aDataPtr;
>
> aDataPtr = new MyData[ 100 ];
> FillUp( aDataPtr, 100 ); // filling up with data
> MySwap< MyData >( aDataPtr + 20, aDataPtr + 40 ); // just
> because.... :-)
> }
>
>
> Thanks in advance for any insight,
> Francesco
>
>
> On Apr 20, 2005, at 7:46 PM, Alfred P. Reaud wrote:
>
>
> Hi Francesco,
>
> Your array of class objects would be better served if it where a list or
> vector of class objects instead of an array. Then you can use the iterator
> features, including list and vector specific swap and sort member functions.
> I f you must use an array of class objects, then there's always the
> <algorithm> standard template library header. Algorithm has a rich set of
> functions that include swap, sort, and other useful data manipulation
> algorithms such as unique, etc. These functions are usually optimized, and
> work in most instances significantly better than manually coded swap or sort
> functions.
>
> I'm not actually sure what you mean by "deep copy", however, I'm assuming
> that you mean actual data copying. You shouldn't be copying data to swap
> it! You should be swapping pointers to the data. Maybe the issue is in
> using a class class_objects[array_size]; declaration vs. a class
> *class_objects; declaration, because the overloaded operator= may operate in
> a different fashion between a pointer and an array element (i.e.
> class_objects[7], is a pointer, but in machine code is actually a set of
> pointer arithmetic operations). The class operator= should already be
> configured to correctly do something like:
>
> class *obj_a, *obj_b, *temp;
> obj_a = new class; ...;
> temp = obj_a; obj_a = obj_b; obj_b = temp;
> delete(temp); ...
>
> so that should work correctly, ***** however *****
>
>
>
> list<class> obj_list;
> list<class>::iterator obj_iter;
> obj_list.push_back(obj_a); ...
> obj_iter = obj_list.begin();
> obj_list.sort() or obj_list.sort( compare_function );
> ...
>
> is easier, more elegant, and uses the optimized features of C++! Hopefully
> the above helps!
>
>
> Francesco <xtr...@vi...> wrote:
> Hi everybody,
> I'm a total beginner and I have the following problem:
> I have an array of objects instantiated from a class that has member
> pointers to dynamically allocated data. This class has also the usual
> overloaded operator=. I have to sort this array and I need to do some
> swapping. But swapping by "deep copy" seems useless to me in this case,
> thus is it possible somehow to override the overloaded operator= and
> use just for the swapping the normal operator =? I could use memcpy for
> a bitwise copy, but it seems to be significantly slower, especially
> for small objects.
> Thanks in advance,
> Francesco
> <snip>
>
>
>
>
> Alfred P. Reaud
> <image.tiff>
> ___________________________________________________________________
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure. If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof. Thank you.
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|