dev-cpp-users Mailing List for Dev-C++ (Page 334)
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
|
|
From: Abhijit S. <mu...@gm...> - 2003-08-05 18:21:19
|
> But this is not the only time I get this kind of error. Are you compiling with optimization (-O2 or greater?). If so, try disabling optimizations and then see if it works. Optimization levels greater than 2 are supposed to be risky. -- Abhijit Shylanath Homepage: http://mudeth.tripod.com/ |
|
From: <ten...@ne...> - 2003-08-05 18:14:35
|
That can't be (the unreachable) because in that case the action which
is taken just down and up shouldn't be done, and they're done.
My code (I forgot that, arj!, I knew I forget something... so I had it
unsent for a week):
case ID_UNIX:
{
int number;
LPTSTR text;
SendMessage(...;
if (!UNIX){
//instructions which are executed
SendMessage(...//The same again
}
}
break;
Anyway I did what you suggested (although with EM_SETMODIFY it's said
the function doesn't return any value. The value of the DWORD variable
where I return the value after calling sendmessage i 1 (dwSi =
SendMessane(...EM_SETMODIFY...); --->dwSi = 1), but has it any sense? If
dosumentation at this point is correct, none) I did a GetLastError there
(but that'a another **** point), and the message box is showed with "no
error".
But this is not the only time I get this kind of error.
Another time I did:
void func(int &tal){
POINT pt;
int y, x;
for (y = 0; y < tal; y++){
for (x = 0; x < tal; x++){
pt.x = x;
pt.y = y;
tal = _setintegerwithapoint(pt);
}
}
}
And neither x nor y are incremented, being tal > 100;
The same if I do pt.y and pt.x instead y and x in the loops; I have to
do the loop with x and y and then call a function which takes them and
makes parameter + 1;
This is only one of so many examples. And the instructions affected are
in the same block that other that are executed.
And if I insert a new line before or I change the order in the code it
is still not done. Although it is a simple instruction like f = j +h;
Abhijit Shylanath wrote:
>Hello, Carlos.
>
>
>
>> ...of lines of code which are not executed.
>>Or functions which does nothing or not what it's claimed they do...
>>e.g.:
>>case ID_LABEL:
>>SendMessage(GetDlgItem(hwnd, ID_EDIT), EM_SETMODIFY, (WPARAM)(UINT)TRUE,
>>0L);
>>break;
>>menu->label
>>menu->quit
>>Oh, SendMessage... EM_GETMODIFY.... says FALSE. Oh, what was
>>EM_SETMODIFY supposed to do. Wasn't it make EM_GETMODIFY return TRUE?????
>>
>>
>
>Maybe a bug in your code (no offence, just a random thought)? Have you
>tried a SendMessage(... EM_SETMODIFY ...) on startup and then immediately a
>dump with the return value from EM_SETMODIFY? Or a MessageBox() on the above
>case? Maybe the code is not reachable.
>
>--
>Abhijit Shylanath
>Homepage: http://mudeth.tripod.com/
>
>
>
>
|
|
From: Abhijit S. <mu...@gm...> - 2003-08-05 17:38:44
|
> Is Multithread supported by Dev C++?? Where are the multithread > libraries?? Yes (not because of any magic by Dev - Windows natively supports multi-threading). Use CreateThread(). -- Abhijit Shylanath Homepage: http://mudeth.tripod.com/ |
|
From: David M. <ci...@ya...> - 2003-08-05 17:06:12
|
OK boy and girls. Other than allocating a block of memory and interpreting each of the bits myself how can I store really big numbers (Let's stick with integers for now) in memory. Signed David Mcken P.S. Also for any of you looking for job security. http://mindprod.com/unmain.html - How To Write Unmaintainable Code __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |
|
From: <a_g...@ya...> - 2003-08-05 14:53:28
|
thanks a lot! Daniel Glenfield <sp...@ho...> wrote:= look in the directories specified in the project options "foo.h" = this header file is in the local directory, so get it from there. >From: Avik Ghose >Reply-To: avi...@ne... >To: dev...@li... >Subject: [Dev-C++] help needed for #include >Date: Tue, 5 Aug 2003 15:08:35 +0100 (BST) > >Hi all, >I have this slight confusion regarding how the two are different. >#include >#include "foo.h" >I mean how does GNU make and gcc differentiate while searching for the >include file in both the cases. >Thanks in advance. >Have a nice day! > > > > >Thanx and Regards > Avik Ghose >SMS using the Yahoo! Messenger;Download latest version. _________________________________________________________________ Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ 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 Thanx and Regards Avik Ghose SMS using the Yahoo! Messenger;Download latest version. |
|
From: Christian W. <Chr...@vo...> - 2003-08-05 14:38:05
|
Hi, =20 =20 in MS CPP cases #include "foo.h" means that it first searches in the directory of your project and then in the standard include-dir of your compiler, in the other case it seaches first in the include-dir of the compiler, and after that in your project dir... =20 (In some cases the compiler searches only in the directory for your = compiler ...) =20 =20 Kind regards=20 =20 =20 Christian -----Urspr=FCngliche Nachricht----- Von: Avik Ghose [mailto:a_g...@ya...]=20 Gesendet: Dienstag, 5. August 2003 16:09 An: dev...@li... Betreff: [Dev-C++] help needed for #include Hi all, I have this slight confusion regarding how the two are different. #include <foo.h> #include "foo.h" I mean how does GNU make and gcc differentiate while searching for the include file in both the cases. Thanks in advance. Have a nice day! =20 Thanx and Regards Avik Ghose=20 Yahoo! India Mobile <http://in.yimg.com/i/in/mobile/pctomob.gif> <http://in.mobile.yahoo.com/new/pc/> SMS using the Yahoo! <http://in.mobile.yahoo.com/new/pc/> Messenger; Download <http://in.messenger.yahoo.com/> latest version. |
|
From: Daniel G. <sp...@ho...> - 2003-08-05 14:22:37
|
<foo.h> = look in the directories specified in the project options "foo.h" = this header file is in the local directory, so get it from there. >From: Avik Ghose <a_g...@ya...> >Reply-To: avi...@ne... >To: dev...@li... >Subject: [Dev-C++] help needed for #include >Date: Tue, 5 Aug 2003 15:08:35 +0100 (BST) > >Hi all, >I have this slight confusion regarding how the two are different. >#include <foo.h> >#include "foo.h" >I mean how does GNU make and gcc differentiate while searching for the >include file in both the cases. >Thanks in advance. >Have a nice day! > > > > >Thanx and Regards > Avik Ghose >SMS using the Yahoo! Messenger;Download latest version. _________________________________________________________________ Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger |
|
From: <a_g...@ya...> - 2003-08-05 14:08:50
|
Hi all, I have this slight confusion regarding how the two are different. #include <foo.h> #include "foo.h" I mean how does GNU make and gcc differentiate while searching for the include file in both the cases. Thanks in advance. Have a nice day! Thanx and Regards Avik Ghose SMS using the Yahoo! Messenger;Download latest version. |
|
From: <or...@vp...> - 2003-08-05 10:45:16
|
Pukara Rob wrote: > Anyway, I am almost giving up in this compilation thing and thinking of > going back to my old linux machine with the nice g++. It seems that the > system (ARIA) works only for visual C++ 6.0 if in windows. So I tried to > cheat the compiler into making it think we were in linux to see what > happens. Then it said that several files are missing. What exactly are the errors you get, if you use the system as intended (I mean for Windows). Why do you think it only works with VC++? What are the errors? > Is Multithread supported by Dev C++?? Where are the multithread libraries?? I don't know about this one. > By the way what "import function of dev"? It is in File->Import, which allows you to import (convert) VC++ 6 project files to Dev-C++ ones. Although, most of the time, you still need to clean up the result, but it does most of the work for you. -- Greetings, Balázs |
|
From: w.y. <yok...@be...> - 2003-08-05 10:28:47
|
FerretallicA wrote: > > I get the following errors when compiling: > > [Linker error] undefined reference to `c_dfDIKeyboard' > [Linker error] undefined reference to `IID_IDirectInput8A' > > I'm currently using the -ldinput8 library as opposed to -ldinput, and the You might possibly need to include both those libs when using Direct Input, at least that's what it says in my book. I've been reading about Direct Input the past few days, but haven't tried anything with it yet. > DirectX 9 headers (though I don't think that makes a difference to using the > DX8 headers, but I've got "#define DIRECTINPUT_VERSION 0x0800" to be sure). Maybe missing this at the top of your program? #define INITGUID or #include<dinput.h> |
|
From: Pukara R. <puk...@ya...> - 2003-08-05 10:20:21
|
Hello Thank you again for answering my question even the strangest ones :) Anyway, I am almost giving up in this compilation thing and thinking of going back to my old linux machine with the nice g++. It seems that the system (ARIA) works only for visual C++ 6.0 if in windows. So I tried to cheat the compiler into making it think we were in linux to see what happens. Then it said that several files are missing. Is Multithread supported by Dev C++?? Where are the multithread libraries?? If anyone has experience here with Visual C++ I would like to read its opijnion By the way what "import function of dev"? Thanks a lot! OROSZI_Bal#30169;s <or...@vp...> wrote: Pukara Rob wrote: > By the way, about the stdio.h file. I think it is pretty neccessary so I > am wondering why these guys chose to leave it out? Has any one of you > worked with Visual C++? Is there a replacemente for the standard stdio.h > there? I asked because the Aria guys provided some project files for VC > but since I work with DevC++... > > About the .. > > #ifdef SOMETHING > ....... > #endif > > how do I define and undefine something from the compiling environment. I > am trying to force it compile because I have lost too much time already. > > By the way ARIA is the name of a control system for Pioneer robots. VC++ project files have nothing to do with includes, as they don't contain any. They may only contain defines, but they are imported by dev anyway (I assume, that you used the import function of dev, no?). I think, that the stdio.h file is the same in Dev-C++ (well, actually in MinGW) and both in VC++. So I really don't know what and why have they done. To define something globally, through the environment, you need to pass a flag to the compiler. It has the form: -DSOMETHING This will define SOMETHING for the currently compiled file. Add -DWHAT_YOU_WANT to the compiler flags in the Project options -> Parameters -> Compiler or C++ compiler. I hope this helps. Good luck! -- Greetings, Bal#30169;s ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ 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 --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software |
|
From: FerretallicA <fer...@ho...> - 2003-08-05 09:55:31
|
Oo oi, I've finally bitten the bullet and decided to use DX with DevC++. I've converted a workspace from an old Visual C++ project and cleaned up everything that needed cleaning up in the conversion except there's still one thing that escapes me. I get the following errors when compiling: [Linker error] undefined reference to `c_dfDIKeyboard' [Linker error] undefined reference to `IID_IDirectInput8A' I'm currently using the -ldinput8 library as opposed to -ldinput, and the DirectX 9 headers (though I don't think that makes a difference to using the DX8 headers, but I've got "#define DIRECTINPUT_VERSION 0x0800" to be sure). Everything else works fine. I've tried my best to find an answer via Google and pouring over message boards but no joy. Help!? Cheers, -FerretallicA |
|
From: Josh H. <jo...@ct...> - 2003-08-05 07:23:48
|
I have a (stupid?) question. Attatched is some code written in Dev C++ 4.01. The code compiles fine using the full Dev C++ 4.01 package (ie. including the Mingw compiler). The problem is that when I try to compile it using the latest beta release of Dev C++ (4.981) I get numerous errors. I am aware that these 2 versions of Dev C++ use different versions of the Mingw compiler, and presume that this is where the problem lies. My question is what is wrong with my code that it doesn't compile under the newer version of Mingw? I have determined that the problem lies in my header file (headers.h), as the project seems to compile fine if I add the line "using namespace std" to the header file, but I don't see why I need to add this line, as I've individually qualified everything that needs qualifying (or am I missing something here?) and I believe it is bad practice to use using declarations in header files. To run the program, redirect one of the candidates.txt files into the program from the command line. ie. type: programName < candidates.txt Any help would be much appreciated. Thanks. |
|
From: Ioannis V. <iv...@em...> - 2003-08-04 22:55:54
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of OROSZI Balazs
> Sent: Tuesday, August 05, 2003 12:10 AM
> To: dev...@li...
> Subject: Re: [Dev-C++] arrays in structures
>
> >
> > M$ says Yes.
> >
> > From MSDN:
> >
> > -- cut here --
> > int prop[3][4][6];
> > ...
> > i = prop[2][1][3];
So what?
> So actually, the whole stuff is stored linearly, and the
> compiler deals
> with multiplication, to get the final address in memory,
> relative to prop.
>
> And another question arose in me, reading the above: multiplication.
> Isn't that slow? I mean, if I use a loop, and I do a lot of indexing,
> that results in a lot of multiplication, no? Wouldn't it be
> better then
> to just incerement the pointer itself. Like, instead of this:
>
> int i,array[100];
> for(i=0;i<100;++i){
> DoSomething(array[i]);
> }
>
> do this:
>
> int *i,array[100];
> for(i=array;i<array+100;++i){
> DoSomething(*i);
> }
>
> Would it be faster?
No, because the compiler undestands indexing as pointer
addition/subtraction.
So your indxing code above is perceived by the compiler as:
int i,array[100];
for(i=0;i<100;++i){
DoSomething(*(array+i));
}
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|
|
From: Ioannis V. <iv...@em...> - 2003-08-04 22:49:44
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of OROSZI Bal?zs
> Sent: Monday, August 04, 2003 5:20 PM
> To: dev...@li...
> Subject: [Dev-C++] loop optimization
>=20
>=20
> Hi!
>=20
> Now, I have a question.
> I need to do heavy optimizations in the project I am working=20
> on, and I=20
> am asking you, whether will I gain any speedup by optimizing=20
> loops. I am=20
> interested in the for loop exactly. Let's take this example:
>=20
> for(i=3D0;i<getint();i++){
> /* ... */
> }
>=20
> Would it worth it to take that getint() into an outer=20
> variable, and only=20
> use that in the conditional, like this:
>=20
> int c =3D getint();
> for(i=3D0;i<c;i++){
> /* ... */
> }
You do not specify language (why?) so I assume C.
In C99 if the function can be inlined (and you have used the keyword =
inline)
it will be inlined so you do not get any gain. If it cannot be inlined =
then
by placing it outside the loop you gain some run-time (the time cost of =
the
subsequent funtion calls, which is much if the calls are many).
>=20
> Will this give me any speedup? I am interested in particular, is for=20
> going to call getint() EVERY time in the first case (on top),=20
> or will it=20
> do it only once? I think the second case is better, am I right?
>=20
> Allright, that was my first question, here is the second:
> What is the case, if the conditional is a KNOWN value.=20
> Something, like a=20
> macro. Here is the example:
>=20
> #define GETINT (10*5)
>=20
> for(i=3D0;i<GETINT;i++){
> /* ... */
> }
>=20
> I suppose, this will be optimised by the compiler, and this=20
> can even be=20
> unrolled, am I right?
Well in theory the compiler can be smart without any limits. The only =
worst
case scenario assumption you can make is that the loop will be executed =
50
times (the GETINT is inlined of course).
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|
|
From: Ioannis V. <iv...@em...> - 2003-08-04 22:40:02
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of OROSZI Bal?zs
> Sent: Monday, August 04, 2003 5:34 PM
> To: dev...@li...
> Subject: [Dev-C++] arrays in structures
>
>
> Hi!
>
> Again, a question. Suppose I have a structure like this:
>
> typedef struct _block{
> int array[16][16];
> int v1;
> int v2;
> }block;
>
> So, my question is, is that array[16][16] stored linearly in the
> structure? Can I do a memcpy directly on it, to copy it
> elsewhere, like
> this:
>
> memcpy(destination->array,source->array,16*16*sizeof(int));
> /* destination*/ /* source*/ /* bytes to copy */
>
> Can I do this?
Yes. But always be careful all the elements of the array to be in the
"automatic storage" (I assume C here) as it is in your case, and not
something like:
int *array[16];
/* ... */
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|
|
From: Daniel K. O. <dan...@ya...> - 2003-08-04 21:52:20
|
OROSZI Balázs wrote:
> So actually, the whole stuff is stored linearly, and the compiler
> deals with multiplication, to get the final address in memory,
> relative to prop.
>
> And another question arose in me, reading the above: multiplication.
> Isn't that slow? I mean, if I use a loop, and I do a lot of indexing,
> that results in a lot of multiplication, no? Wouldn't it be better
> then to just incerement the pointer itself. Like, instead of this:
>
> int i,array[100];
> for(i=0;i<100;++i){
> DoSomething(array[i]);
> }
>
> do this:
>
> int *i,array[100];
> for(i=array;i<array+100;++i){
> DoSomething(*i);
> }
>
> Would it be faster?
With a good compiler, both of them should be identical. The question
"which is faster" you can test yourself, using clock() before and after
the calls, and see what you get.
Daniel K. O.
|
|
From: Michael D. S. <for...@hi...> - 2003-08-04 21:51:24
|
> "the results are stored in memory (this is for reasons of speed). endl
makes sure that they (the
> files or devices) are updated."
Well sorta'. It does flush it out of the buffer but then the channel
program picks it up and it also has a queue. A networked printer at a big
company could develop a queue during the day long enough to print well into
the night but printers are very slow. With a disk it's generally seconds or
at most minutes but that's still forever to the CPU, the channel program
queue (disk swap area) keeps it from having to wait. OK, as much, even
writing to main memory is slow to the cpu.
Mostly this detail doesn't matter but if you're programming CGI and
wondering why your files are getting corrupted, this is the reason. A
second hit tries to read before the write from the first has cleared the
queue. Because of the queue and because a shared server has a lot of other
traffic (also in the queue), this doesn't take near as much traffic to your
site as you might think. A hundred hits a day can do it, mostly because
much like the freeways everyone seems to want to go at once.
File locks are the answer to that problem -- if you can get 'em to work.
Usually 8k is the most efficient buffer size for a disk drive and if you're
writing that much or more you should allow it use it's optimum buffer size.
If you're only writing a few lines or you have a need for speed, for CGI or
whatever reason, a buffer flush is what you want.
Still I wouldn't do this:
cout << "line one"
<< endl
<< "line two"
<< endl;
but rather this:
cout << "line one\nline two"
<< endl;
I know that's so little and the computer is so fast that it's practically
irrelevant, but I like to feel I'm doing the best I can anyway:)
ms
If at first you don't succeed, destroy all evidence that you tried
At 03:51 AM 8/4/03, you wrote:
>To just add a small amount to Abhijit's reply, think of it like this: '\n'
>(note: _not_ '/n') is just a character, but endl is a function that can do
>all sorts of things in addition to just adding a character or two to the
>output stream.
>
>Abhijit Shylanath wrote:
>
>>Hello, Graham.
>>
>>
>>
>>>My book defines "/n" as new line.
>>>And defines " endl " as end line.
>>>But gives me no clue as to what the difference is or when to use which.
>>>can anyone explain the difference to me ?
>>>
>>
>>Two differences you should know:
>>
>> '\n' is new-line to C, and to Unix, but may not be new-line to your OS.
>>For example, for Windows, "\r\n" is new-line. IIRC, for macs, it's just
>>'\r'. endl takes care of these platform specific thingies for you (as a
>>matter of fact, so does '\n' in files opened in text mode in STDIO, but endl
>>is a more graceful and conformant solution.
>>
>> Next, endl makes sure that the text that you've written is flushed. Most
>>streams have a buffer, so that when you write to them, the connected device
>>or file is not updated instantly, but the results are stored in memory (this
>>is for reasons of speed). endl makes sure that they (the files or devices)
>>are updated.
>>
>> If in doubt, use endl. If you're working with raw data (binary files or
>>such), then you will have to use '\n'. When you start working with binary
>>files, you should be able to tell the difference anyway, if your book is any
>>good.
>>
>>Hope this helps.
>>
>>--
>>Abhijit Shylanath
>>Homepage: http://mudeth.tripod.com/
>>
>>
>>-------------------------------------------------------
>>This SF.Net email sponsored by: Free pre-built ASP.NET sites including
>>Data Reports, E-commerce, Portals, and Forums are available now.
>>Download today and enter to win an XBOX or Visual Studio .NET.
>>http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
>>_______________________________________________
|
|
From: <or...@vp...> - 2003-08-04 21:09:57
|
Abhijit Shylanath wrote:
>>Hi!
>>
>>Again, a question. Suppose I have a structure like this:
>>
>> typedef struct _block{
>> int array[16][16];
>> int v1;
>> int v2;
>> }block;
>>
>>So, my question is, is that array[16][16] stored linearly in the
>>structure? Can I do a memcpy directly on it, to copy it elsewhere, like
>>this:
>
>
> M$ says Yes.
>
> From MSDN:
>
> -- cut here --
> int prop[3][4][6];
> ...
> i = prop[2][1][3];
>
> This statement is a more complex reference to an individual element of prop.
> The expression is evaluated as follows:
>
> The first subscript, 2, is multiplied by the size of a 4-by-6 int array and
> added to the pointer value prop. The result points to the third 4-by-6 array
> of prop.
>
> The second subscript, 1, is multiplied by the size of the 6-element int
> array and added to the address represented by prop[2].
>
> Each element of the 6-element array is an int value, so the final subscript,
> 3, is multiplied by the size of an int before it is added to prop[2][1]. The
> resulting pointer addresses the fourth element of the 6-element array.
>
> The indirection operator is applied to the pointer value. The result is the
> int element at that address.
> -- cut here --
So actually, the whole stuff is stored linearly, and the compiler deals
with multiplication, to get the final address in memory, relative to prop.
And another question arose in me, reading the above: multiplication.
Isn't that slow? I mean, if I use a loop, and I do a lot of indexing,
that results in a lot of multiplication, no? Wouldn't it be better then
to just incerement the pointer itself. Like, instead of this:
int i,array[100];
for(i=0;i<100;++i){
DoSomething(array[i]);
}
do this:
int *i,array[100];
for(i=array;i<array+100;++i){
DoSomething(*i);
}
Would it be faster?
--
Greetings,
Balázs
|
|
From: Abhijit S. <mu...@gm...> - 2003-08-04 20:35:01
|
> Hi!
>
> Again, a question. Suppose I have a structure like this:
>
> typedef struct _block{
> int array[16][16];
> int v1;
> int v2;
> }block;
>
> So, my question is, is that array[16][16] stored linearly in the
> structure? Can I do a memcpy directly on it, to copy it elsewhere, like
> this:
M$ says Yes.
From MSDN:
-- cut here --
int prop[3][4][6];
...
i = prop[2][1][3];
This statement is a more complex reference to an individual element of prop.
The expression is evaluated as follows:
The first subscript, 2, is multiplied by the size of a 4-by-6 int array and
added to the pointer value prop. The result points to the third 4-by-6 array
of prop.
The second subscript, 1, is multiplied by the size of the 6-element int
array and added to the address represented by prop[2].
Each element of the 6-element array is an int value, so the final subscript,
3, is multiplied by the size of an int before it is added to prop[2][1]. The
resulting pointer addresses the fourth element of the 6-element array.
The indirection operator is applied to the pointer value. The result is the
int element at that address.
-- cut here --
Multi-line URL follows:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html
/_clang_multidimensional_arrays.asp
--
Abhijit Shylanath
Homepage: http://mudeth.tripod.com/
|
|
From: <or...@vp...> - 2003-08-04 19:45:11
|
Abhijit Shylanath wrote: > This might give you more info: > http://computational-battery.org/Tools/gcc-opt-guide.html > > There are a couple of links at the bottom of the page that you should read, > too. Thanks for all your help both. I apreciate it. However, I use C only now. BTW, could you look at my second mail also. That would be very great for me. Thanks! -- Greetings, Balázs |
|
From: Abhijit S. <mu...@gm...> - 2003-08-04 19:11:36
|
Hello, Carlos. > ...of lines of code which are not executed. > Or functions which does nothing or not what it's claimed they do... > e.g.: > case ID_LABEL: > SendMessage(GetDlgItem(hwnd, ID_EDIT), EM_SETMODIFY, (WPARAM)(UINT)TRUE, > 0L); > break; > menu->label > menu->quit > Oh, SendMessage... EM_GETMODIFY.... says FALSE. Oh, what was > EM_SETMODIFY supposed to do. Wasn't it make EM_GETMODIFY return TRUE????? Maybe a bug in your code (no offence, just a random thought)? Have you tried a SendMessage(... EM_SETMODIFY ...) on startup and then immediately a dump with the return value from EM_SETMODIFY? Or a MessageBox() on the above case? Maybe the code is not reachable. -- Abhijit Shylanath Homepage: http://mudeth.tripod.com/ |
|
From: Abhijit S. <mu...@gm...> - 2003-08-04 18:53:43
|
> If I compile a Windows version with Dev C++ here on my old '98 > box, will it > work on all Windows systems or just some -- is a 9x version, a 2000 > version, a XP version necessary? That depends on what API functions you're calling. Your reference should tell you whether a function is 95/98/ME/NT/2000/XP-specific. If it doesn't, check MSDN. http://msdn.microsoft.com/ > Keep in mind, this CGI isn't a lot more > than "Hello World." It's purpose is to output some text (HTML) to > standard > out. If I was creating a window of course it would be Windows > specific. But > even setting up standard out could be, probably is, platform > specific so... You might want to try a cross-platform GUI toolkit - FLTK would be right for you: http://fltk.sourceforge.net/ It's named that because it's Fast Light ToolKit. That's bogus (the name, not the fast-light), but it's a fact (the fast-light, not the name). BTW, if you create a window in CGI, it will show up not on the viewer's screen, but on the server's screen. I hope you're clear about that. If you want a window on the viewer's screen, you'll need to use JavaScript or some such badness (or maybe Java - but is it really worth it?). OT, I sincerely recommend that you use Perl-CGI instead of C... it's much more friendly and easily-extendable. -- Abhijit Shylanath Homepage: http://mudeth.tripod.com/ |
|
From: Abhijit S. <mu...@gm...> - 2003-08-04 18:44:04
|
Hello, Oroszi.
> for(i=0;i<getint();i++){
> /* ... */
> }
>
> Would it worth it to take that getint() into an outer variable, and only
> use that in the conditional, like this:
>
> int c = getint();
> for(i=0;i<c;i++){
> /* ... */
> }
>
> Will this give me any speedup?
I don't know about the working of gcc, so this I don't know if this will be
optimized. However, there's no loss in doing this, and I guess you should
(so that even if gcc, or whatever compiler you want to move it onto doesn't
optimize it, you get the fastest code). Without optimization, the second
will definitely be better than the first, since in case 1, on every
iteration, there's the overhead of the function call, and in case 2, that is
eliminated.
> I am interested in particular, is for
> going to call getint() EVERY time in the first case (on top), or will it
> do it only once? I think the second case is better, am I right?
I think I answered that already.
> Allright, that was my first question, here is the second:
> What is the case, if the conditional is a KNOWN value. Something, like a
> macro. Here is the example:
>
> #define GETINT (10*5)
>
> for(i=0;i<GETINT;i++){
> /* ... */
> }
There is no need for optimization at all here, because the compiler will see
this as:
for(i = 0; i < (10*5); i++) { [whatever] }
So that's a constant already. The unrolling may be done by the compiler
itself (there was a flag -funroll-loops, I'm not sure, you should check that
out).
The postfix/prefix conversion indicated by Charles will help only for
user-defined classes, not for primitives. Also, I think gcc optimizes this
automatically.
This might give you more info:
http://computational-battery.org/Tools/gcc-opt-guide.html
There are a couple of links at the bottom of the page that you should read,
too.
--
Abhijit Shylanath
Homepage: http://mudeth.tripod.com/
|
|
From: Vale G. <val...@at...> - 2003-08-04 18:25:08
|
Balázs -
> I need to do heavy optimizations in the project I am working on, and I am
asking you, whether will I gain any speedup by optimizing loops.
> for(i=0;i<getint();i++){...}
The only way to know for sure whether and where you need to optimize the code is
to run the profile program on it.
That said, I would suggest changing the increment operator from postfix to
prefix.
for (i=0; i<getint(); ++i)
See:
http://www.tantalon.com/pete/cppopt/asyougo.htm
http://www.devx.com/cplus/Article/16328/0/page/4
It probably doesn't matter much; your compiler may already be optimizing this
code for you.
Charles
|