dev-cpp-users Mailing List for Dev-C++ (Page 246)
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: Emiliano <sky...@fa...> - 2004-02-27 16:44:49
|
First of all, thank you again for your precious hints. ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Emiliano" <sky...@fa...> Cc: <dev...@li...> Sent: Friday, February 27, 2004 4:30 PM Subject: Re: [Dev-C++] WinAPI help... > Unless this is a movie viewer or similar, where the drawed material > requires a fixed frame rate, you shouldn't create the code for a fixed > frame rate, since you can't know the speed of the machine, and amount of > other programs currently needing processing time. No, I need just to update the 3d world at regular time intervals. Of course, the updating function is supposed to be simple and fast. > You might use GetTickCount() to getch which millisecond you started draw. > When the thread has drawn everything, it calls GetTickCount() again. The > difference between these two represents number of used ms. You may then > Sleep(xx-consumed) ms. Call GetTickCount() and check how lock you slept > since all you know is that the program slept >= xx-consumed. > The disadvantage with the above solution is that if the drawing takes >= > allowed time, the machine will spend 100% of available capacity drawing. > You might instead define that it is the sleep time between end of one > frame and start of drawing of next frame that should fixed. Yes, but if I'm not wrong, in this way I could have a very fast world when the scene is simple, and a very slow one when the scene is full of stuff. > You might also use the DirectX methods for drawing your information - they > have functions for synchronizing frame rates. Alas, I don't know how to > program with DirectX in the Dev-C++ environment. I have only tried this > with M$ VC++. I think DX won't work with dev-cpp, uh? :)) > About your "strage" framerate: Windows tries to run threads for full > time slices before swapping. Thread with the timer func: "GetMessage() -> Dispatch()" (the doc says that with a TimerFunc, no message is posted to the thread queue... but I still need GetMessage() for it to work!!!) Thread handling the window: "GetMessage() -> Dispatch()" Thread performing the drawing: "WaitForSingleObject() -> draw()" Two more questions: 1) I have the timer running as HIGHEST priority, main task is normal and drawing task IDLE. Has this something to do with time slices given to each thread? I thougt that with Wait/GetMessage each thread went active only when it had a message waiting... 2) Sometime I press esc, a PostQuitMessage(0); is issued (as the debug output says)... but I must be losing it, since the program goes on!! Or the win thread goes into starvation?? I can't say. thanks again, Emiliano |
|
From: William Mc C. <WIL...@ms...> - 2004-02-27 15:47:24
|
Hi Guys:
Just a Joke to remove your stress:
A 70 year old man went to the Doctor's for a Physical. The Doctor ran
some tests and said to the man, "Well everything seems to be in top
condition physically, but what about mentally? How is your connection with
God?" And the man answered "Oh me and God? We have a really tight bond, He's
so good to me.
Every night when I get up to go to the bathroom, He turns on the light for
me, and then, when I leave, He turns it back off". The Doctor was
astonished. He called the man's wife and said "I'd like to speak to you
about your husband's connection with God. He claims that every night when he
needs to use the restroom, God turns the light on for him and turns it off
again when he leaves. Is this true?" And she replied, "That idiot, He's been
peeing in the refrigerator again!"
|
|
From: Per W. <pw...@ia...> - 2004-02-27 15:41:22
|
Unless this is a movie viewer or similar, where the drawed material requires a fixed frame rate, you shouldn't create the code for a fixed frame rate, since you can't know the speed of the machine, and amount of other programs currently needing processing time. You might use GetTickCount() to getch which millisecond you started draw. When the thread has drawn everything, it calls GetTickCount() again. The difference between these two represents number of used ms. You may then Sleep(xx-consumed) ms. Call GetTickCount() and check how lock you slept since all you know is that the program slept >= xx-consumed. The disadvantage with the above solution is that if the drawing takes >= allowed time, the machine will spend 100% of available capacity drawing. You might instead define that it is the sleep time between end of one frame and start of drawing of next frame that should fixed. You might also use the DirectX methods for drawing your information - they have functions for synchronizing frame rates. Alas, I don't know how to program with DirectX in the Dev-C++ environment. I have only tried this with M$ VC++. About your "strage" framerate: Windows tries to run threads for full time slices before swapping. /Per W On Fri, 27 Feb 2004, Emiliano wrote: > To any Win programmer listening... who would be sure better than me :) > > I have this problem: I have a 3 threaded app. One thread is for timing, one > for drawing, and the last reads windows messages. > > I need a working temporization. I've used both the "TimerFunc()" and the > "Sleep()" functions in the timer thread but both don't seem to be too > precise. The timer thread uses an Event object to awake the drawing thread. > > I used a timeout of 20 ms and I get 32 fps (instead of 50). I've tried with > 10 ms, and I get 64 fps :D instead of 1000/10 = 100...!! I know I can reach > that speed, since I draw a very simple scene, and my system can do it > (tested with other apps), and the video-refresh of my current video mode is > right 100-101 Hz. > > Is there some better way to achieve decent temporization? some library that > allows using interrupts or something similar? > > thanks in advance, > Emiliano > > PS I need this for an OpenGL program, I've only found nasty busy-waiting > loops with "PeekMessage()" and some drawFrame() + SwapBuffers() elsewhere... > that works ok most of the time, but if you try to put your window in the > background, the CPU usage reaches instantly 100%, and that sucks!! > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&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: Per W. <pw...@ia...> - 2004-02-27 15:18:59
|
First of all - your create template function is declared to return void,
so why do you end it with return ptr?
Second, you send in a T* ptr parameter. Note that since C++ uses
call-by-value, this will behave like a lokal variable, i.e any assign to
ptr will not reflect back to the caller. You should change the first
parameter of create to be a reference to a pointer. That way, the assign
to ptr will reflect back to the variable obj of the caller.
/Per W
On Fri, 27 Feb 2004, David McKen wrote:
> Ok here is my problem.
>
> I want to replace:
> #define CREATE(result, type, number) \
> do \
> { \
> if (!((result) = (type *) calloc ((number), sizeof(type)))) \
> { \
> perror("malloc failure"); \
> fprintf(stderr, "Malloc failure @ %s:%d\n", __FILE__, __LINE__ );
> \
> abort(); \
> } \
> } while(0)
>
> With it's C++ equivalent.
>
> So far I have:
> #define CREATE(result, type, num) = create<type>((result),(num))
> template<class T>
> void create(T * ptr, int number, char * f_name = __FILE__, int l_num
> =
> __LINE__)
> {
> try {
> ptr = new T[number];
> }
> catch(bad_alloc& b)
> {
> perror("malloc failure");
> fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
> abort();
> }
> if ( !ptr )
> {
> perror("malloc failure");
> fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
> abort();
> }
> return ptr;
> }
>
> But the program crashes after the function call when any attempt to
> acces
> the data occours:
> e.g.
> OBJ_DATA * obj;
> CREATE( obj , OBJ_DATA, 1 );
>
> obj->some_field = 5; //Crashes here and obj = 0x0 from gdb.
>
> Thanks in Advance
> David McKen
>
>
> __________________________________
> Do you Yahoo!?
> Get better spam protection with Yahoo! Mail.
> http://antispam.yahoo.com/tools
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&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: Emiliano <sky...@fa...> - 2004-02-27 15:02:34
|
To any Win programmer listening... who would be sure better than me :) I have this problem: I have a 3 threaded app. One thread is for timing, one for drawing, and the last reads windows messages. I need a working temporization. I've used both the "TimerFunc()" and the "Sleep()" functions in the timer thread but both don't seem to be too precise. The timer thread uses an Event object to awake the drawing thread. I used a timeout of 20 ms and I get 32 fps (instead of 50). I've tried with 10 ms, and I get 64 fps :D instead of 1000/10 = 100...!! I know I can reach that speed, since I draw a very simple scene, and my system can do it (tested with other apps), and the video-refresh of my current video mode is right 100-101 Hz. Is there some better way to achieve decent temporization? some library that allows using interrupts or something similar? thanks in advance, Emiliano PS I need this for an OpenGL program, I've only found nasty busy-waiting loops with "PeekMessage()" and some drawFrame() + SwapBuffers() elsewhere... that works ok most of the time, but if you try to put your window in the background, the CPU usage reaches instantly 100%, and that sucks!! |
|
From: David M. <ci...@ya...> - 2004-02-27 14:45:41
|
Ok here is my problem.
I want to replace:
#define CREATE(result, type, number) \
do \
{ \
if (!((result) = (type *) calloc ((number), sizeof(type)))) \
{ \
perror("malloc failure"); \
fprintf(stderr, "Malloc failure @ %s:%d\n", __FILE__, __LINE__ );
\
abort(); \
} \
} while(0)
With it's C++ equivalent.
So far I have:
#define CREATE(result, type, num) = create<type>((result),(num))
template<class T>
void create(T * ptr, int number, char * f_name = __FILE__, int l_num
=
__LINE__)
{
try {
ptr = new T[number];
}
catch(bad_alloc& b)
{
perror("malloc failure");
fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
abort();
}
if ( !ptr )
{
perror("malloc failure");
fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
abort();
}
return ptr;
}
But the program crashes after the function call when any attempt to
acces
the data occours:
e.g.
OBJ_DATA * obj;
CREATE( obj , OBJ_DATA, 1 );
obj->some_field = 5; //Crashes here and obj = 0x0 from gdb.
Thanks in Advance
David McKen
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
|
|
From: Fabio S. <fa...@ac...> - 2004-02-27 11:32:37
|
--=20 []s Fabio Sena |
|
From: takwirira t. <ta...@ya...> - 2004-02-27 09:26:37
|
A beatiful young lady is the work of nature but a beatiful old woman is the work of art --------------------------------- Do you Yahoo!? Get better spam protection with Yahoo! Mail |
|
From: Mario B. <st...@vi...> - 2004-02-27 06:08:35
|
Hi Koen, On Thu, 26 Feb 2004 19:51:37 +0100, Koen Stoop <ko...@pa...> wrote: >I'm having problems to debug programs on my WinXP (Home Edition) box. When I >launch the 'debug mode' (after successful compilation and run) , an error >message "An Acces Violation (Segmentation Fault) raised in your program" >appears on the screen and the Insight program hangs. Maybe it's your program that's crashing? I don't know about using Insight but when I get that kind of crash while debugging with gdb, I go to the "Backtrace" tab and ususally find out that the crash was produced by an error in the code... -- Mario B. My Landsat images: http://pages.infinit.net/starged/landsat/home.html |
|
From: Mario B. <st...@vi...> - 2004-02-27 06:08:35
|
Hi Don and all, Once again, I had forgotten to check if I replied to the list or not... could somebody add the "Reply-to: Dev...@li..." field in the headers please? :) On Thu, 26 Feb 2004 11:50:53 -0700, Don Raikes <dnr...@ho...> wrote: >I need to statically link my application to a comercially provided .dll file. > I have the .h and .lib files associated with the dll file. > >How do I tell dev-cpp to link to the dll? I just learned recently (yeah, I'm new at this too :) ) that we can link directly with a dll. According to the ld docs: "The cygwin/mingw ports of ld support the direct linking, including data symbols, to a dll without the usage of any import libraries" "... All that is needed from the developer's perspective is an understanding of this search, in order to force ld to select the dll instead of an import library. For instance, when ld is called with the argument -lxxx it will attempt to find, in the first directory of its search path, libxxx.dll.a xxx.dll.a libxxx.a cygxxx.dll (*) libxxx.dll xxx.dll" So all that you have to do in Dev-cpp is to add the -lxxx in Project options/Parameters/Linker. I tried it and it does work. Hope this helps. -- Mario B. My Landsat images: http://pages.infinit.net/starged/landsat/home.html |
|
From: Mario B. <st...@vi...> - 2004-02-27 05:38:36
|
Hi OROSZI, On Thu, 26 Feb 2004 22:23:27 +0100, OROSZI Bal=E1zs = <or...@vp...> wrote: >I read something about the new release of Dev-C++, that it uses new=20 >tools of MinGW, however I haven't tried it yet. Perhaps they switched to= g++ -shared? I don't know. Since v 4.8.4 or so, I d/l only the exe (since the online = update always fail). Anyway, I would be surprised if this mattered. And I have the latest MinGW tools. >Anyway, as for your release, you have to live with dllwrap. Not necessarily, see below... >BTW, g++ -shared is *MUCH* faster (10 to 20 times) and is the right way=20 >of creating DLLs, since almost 3 years. I don't know why didn't the devs= =20 >of Dev-C++ change it... I don't even know if they are monitoring that particular ml (are you, = guys?)... we don't see too many replies from them here. And you're right, the speed is amazing! The only workaround is to let Dev-cpp generate the Makefile.win as usual = and then edit the $(BIN) line in this file as follows: $(BIN): $(LINKOBJ) $(DLLWRAP) -Wl,-output-def,$(DEFFILE) -Wl,-out-implib,$(STATICLIB) = $(LINKOBJ) $(LIBS) -o $(BIN) and then save it under another name and make the project use it. Of course, DLLWRAP=3Dgcc -shared... Bye! -- Mario B. My Landsat images: http://pages.infinit.net/starged/landsat/home.html |
|
From: Vale G. <val...@at...> - 2004-02-27 04:04:20
|
Ben - > ...I can no longer perform execute->profile analysis. > Does everyone else have the same problem with 4.9.8.7, or is this a me-specific bug? Else, is this a true bug, and is there a bug report for it yet (I cant find one), and are there any workarounds being mooted? It's a known bug which has just been fixed (but not yet released). Colin closed the bug report a few days ago. See http://sourceforge.net/tracker/index.php?func=detail&aid=897081&group_id=10639&a tid=110639 for Bug 897081, "Profiling + debugging -> error in makefile" and a workaround." Chuck |
|
From: Ben M. \(finlaylabs\) <bm...@fi...> - 2004-02-27 03:15:44
|
Hi All, Dec-C++ continues to impress me as a great open-src resource. In having = made the jump to 4.9.8.7 however I can no longer perform = execute->profile analysis. I have requested code profiling and generate debugging info in the = project options manually, responded yes when I am prompted that I havent = turned them on yet and would I like to and recompile, done rebuild-alls, = and run the program many times when prompted that 'please run the = project at least once so that profiling info is generated...", both = using the 'window-shaped run button', execute->run, and in my own = command prompt. I have done all of the above in many combinations, = restarted Dev-C++, restarted the computer, but all to no avail. I cannot = profile my code anymore. I updated from 4.9.8.5, where profiling worked, by downloading = devcpp4987.zip from the web and extracting. I am running Dev-C++ on Toshiba satellite running WinXP home with all = updates. Does everyone else have the same problem with 4.9.8.7, or is this a = me-specific bug? Else, is this a true bug, and is there a bug report for = it yet (I cant find one), and are there any workarounds being mooted? If = not i will delete all Dev_C++ files and start again with a complete = fresh install, or maybe roll-back to .5 as I need profiling. Thanks, Ben Mclean |
|
From: <wa...@wa...> - 2004-02-27 01:32:53
|
On 27 Feb 2004 at 1:24, Per Westermark wrote: > What different memory model? My understanding, which apparently was totally false, was that in C, things like int varname[10][10] were allocated onto the heap and in C++ were allocated onto the stack unless specifically put onto the heap with new. I'd gotten that impression from some things I'd read in Eckel's Thinking in C++ and, iirc, Meyer's Effective C++. I'll see if I can find what made me think that and post references. (But I don't think that mistake invalidates the method I used to create the doubly subscripted array.) Sorry if I caused anyone confusion. Watson (the pencil neck) Davis |
|
From: Per W. <pw...@ia...> - 2004-02-27 00:35:16
|
What different memory model?
The memory layout of an array is identical between C and C++. The only
difference is that when dynamically allocating, you normally use
new/delete or new[]/delete[] since they are type-safe and will call
constructors/destructors.
Note that depending on compiler and environment, large objects on the
stack may create problems. Some environments allows the stack to grow by
use of guard pages, i.e. the stack is only allocated a page at a time, and
at the end of the stack is an extra page which is basically
write-protected. If the program tries to write to this page, an exception
is generated and the OS will then notice that it was the guard page that
was accessed. It will then change the guard page to a normall read/write
page and then allocate a new guard page directly after the previous guard
page. The advantage of this concept is that the system doesn't have to
statically allocate huge stacks that may never be used. The disadvantage
is that if a program allocates a very large array and doesn't access it in
increasing order, the program may make an access AFTER the guard page,
with a failure as a result. Some compilers have an option to add extra
code to step-by step grow the stack in case a function has more
auto-variables than what fits in a memory page.
Let's say the machine has a page size of 4kB and dynamically grows the
stack using guard pages. The following function will then fail unless the
compiler adds extra code:
void foobar() {
char array[4096];
int var;
// This stack access makes a jump of >= 4kB and may totally miss
// the guard page in case the array variable was placed on the
// first byte of the guard page.
var = 10;
}
/Per W
On Thu, 26 Feb 2004 wa...@wa... wrote:
> On 27 Feb 2004 at 0:16, risto holopainen wrote:
>
> > Initialising arrays of large size seems to be a problem - the programs
> > are compiled without warnings, but if the array (or multidimensional
> > array) exceeds some specific size, the program crashes. Has anyone of
> > you had the same problem, and is there anything to fix that? A related
> > question that I have not found answered in my programming textbooks:
> > How is a multidimensional array dynamically initialised? In other
> > words, this works:
> > double *ar;
> > ar = new double[10];
> > but what is the correct syntax for initialising for example ar[10][10]
> > with new?
>
> The problem is that the C and C++ memory models are different.
>
> C++ sees something like double ar[10][10] and builds that on the
> stack. You quickly run out of space and start stepping on things
> that way. I had the same problem when I came from C to C++ (a short
> time ago.)
>
> So, you should either consider using vectors or set it up as a
> pointer to pointers (double **ar) and then initialize it like:
>
> // init 10 pointers to double.
> ar = new double *[10];
>
> // init each pointer to double to a pointer to double.
> for (int i=0; i < 10; i++)
> ar[i] = new double[10];
>
> At least... that's the way I've been doing it but I'm still new to
> C++.
>
> Oh, and be sure to delete them when you're done.
>
>
> HTH.
>
> Watson (the pencil neck) Davis
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&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: Per W. <pw...@ia...> - 2004-02-27 00:24:16
|
Two alternatives for dynamic allocation of multidimensional arrays.
int main() {
typedef int Matrix10[10][10];
int **vec;
Matrix10 *vec2;
int i,j;
vec = new int*[10];
for (i = 0; i < 10; i++) {
vec[i] = new int[10];
for (j = 0; j < 10; j++)
vec[i][j] = 0;
}
vec2 = new Matrix10[1];
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
(*vec2)[i][j] = 0;
return 0;
}
/Per W
On Thu, 26 Feb 2004, Nicolas Rosner wrote:
> > How is a multidimensional array dynamically initialised? In other
> > words [...]
> > what is the correct syntax for initialising for example ar[10][10]
> > with new?
>
> That syntax will work with static variables, i.e.
>
> int arr[10][10];
>
> But it won't work at all with new. You will need to declare the array
> as if it were one-dimensional, i.e.
>
> int* arr = new int[num_rows * num_cols];
>
> and then do the math "by hand" when accessing elements, e.g.
>
> arr[x * num_cols + y] = foo;
>
> I can already hear you screaming "but that totally sucks! the language
> should provide a better way to do it!", but before you do so, please
> remember that arrays are and have always been very low-level in C and
> C++. If you want nicer syntax, all you have to do is write a Matrix
> class to encapsulate the array, or even better, get one of the several
> excellent ones that already exist out there.
>
> For a more thorough discussion of this issue, check out the C++ FAQ
> Lite:
>
> http://www.parashift.com/c++-faq-lite/freestore-mg
|
|
From: <wa...@wa...> - 2004-02-27 00:20:51
|
On 27 Feb 2004 at 0:16, risto holopainen wrote: > Initialising arrays of large size seems to be a problem - the programs > are compiled without warnings, but if the array (or multidimensional > array) exceeds some specific size, the program crashes. Has anyone of > you had the same problem, and is there anything to fix that? A related > question that I have not found answered in my programming textbooks: > How is a multidimensional array dynamically initialised? In other > words, this works: > double *ar; > ar = new double[10]; > but what is the correct syntax for initialising for example ar[10][10] > with new? The problem is that the C and C++ memory models are different. C++ sees something like double ar[10][10] and builds that on the stack. You quickly run out of space and start stepping on things that way. I had the same problem when I came from C to C++ (a short time ago.) So, you should either consider using vectors or set it up as a pointer to pointers (double **ar) and then initialize it like: // init 10 pointers to double. ar = new double *[10]; // init each pointer to double to a pointer to double. for (int i=0; i < 10; i++) ar[i] = new double[10]; At least... that's the way I've been doing it but I'm still new to C++. Oh, and be sure to delete them when you're done. HTH. Watson (the pencil neck) Davis |
|
From: Nicolas R. <ni...@bo...> - 2004-02-27 00:04:47
|
> How is a multidimensional array dynamically initialised? In other=20
> words [...]
> what is the correct syntax for initialising for example ar[10][10]=20
> with new?
That syntax will work with static variables, i.e.
int arr[10][10];
But it won't work at all with new. You will need to declare the array=20
as if it were one-dimensional, i.e.
int* arr =3D new int[num_rows * num_cols];
and then do the math "by hand" when accessing elements, e.g.
arr[x * num_cols + y] =3D foo;
I can already hear you screaming "but that totally sucks! the language=20=
should provide a better way to do it!", but before you do so, please=20
remember that arrays are and have always been very low-level in C and=20
C++. If you want nicer syntax, all you have to do is write a Matrix=20
class to encapsulate the array, or even better, get one of the several=20=
excellent ones that already exist out there.
For a more thorough discussion of this issue, check out the C++ FAQ=20
Lite:
http://www.parashift.com/c++-faq-lite/freestore-mgmt.html
paragraphs [16.15] and [16.16].
By the way, is googling for 'multidimensional arrays C++' that hard? :-)
Regards,
Nicol=E1s
|
|
From: risto h. <rh...@on...> - 2004-02-26 23:26:53
|
Initialising arrays of large size seems to be a problem - the programs are compiled without warnings, but if the array (or multidimensional array) exceeds some specific size, the program crashes. Has anyone of you had the same problem, and is there anything to fix that? A related question that I have not found answered in my programming textbooks: How is a multidimensional array dynamically initialised? In other words, this works: double *ar; ar = new double[10]; but what is the correct syntax for initialising for example ar[10][10] with new? Risto Holopainen |
|
From: <or...@vp...> - 2004-02-26 21:33:16
|
Mario Beauchamp wrote: >>(objects) -Wl,-output-def libgeotiff.def,-out-implib libgeotiff.a -o .= ./../../.libs/geotiff.dll >=20 > Of course, this should be -Wl,-output-def,libgeotiff.def,-out-implib,li= bgeotiff.a... > Anyway, it's not the problem :) I think there is no way to tell Dev-C++ to use g++ -shared. I tried it=20 desparately some time ago. I read something about the new release of Dev-C++, that it uses new=20 tools of MinGW, however I haven't tried it yet. Perhaps they switched to=20 g++ -shared? Anyway, as for your release, you have to live with dllwrap. BTW, g++ -shared is *MUCH* faster (10 to 20 times) and is the right way=20 of creating DLLs, since almost 3 years. I don't know why didn't the devs=20 of Dev-C++ change it... -- Greetings, Bal=E1zs |
|
From: Don R. <dnr...@ho...> - 2004-02-26 19:02:25
|
Hi all, I need to statically link my application to a comercially provided .dll = file. I have the .h and .lib files associated with the dll file. How do I tell dev-cpp to link to the dll? |
|
From: Koen S. <ko...@pa...> - 2004-02-26 19:01:32
|
Hi, =20 I'm new to the dev-cpp programming environment. I've installed version 4.9.8.7 along with the Insight5 debugger. I'm having problems to debug programs on my WinXP (Home Edition) box. = When I launch the 'debug mode' (after successful compilation and run) , an = error message "An Acces Violation (Segmentation Fault) raised in your program" appears on the screen and the Insight program hangs. Any clues on this would be appreciated. I've searched your mailing list, = but couldn't find anything relevant. =20 Thanks, koesto |
|
From: Matthew O. <ma...@oz...> - 2004-02-26 13:24:45
|
GUI programming is very complicated but you can start with a good library. Check out : http://www.wxwindows.org/ They have lots of examples and tutorials. Again it's not easy to understand if you're new to C++. You can download the wxWindows package for Dev-C++ and it also includes wizards to get you started. Programming GUI's means you must have good understanding classes. If your looking to write a simple application I would recommend Visual Basic or even get your feet wet with Visual Basic for Applications(VBA) which comes with Microsoft Office ( hit Alt-F11 in any office program ) Good luck Matthew Ozor www.ozor.net -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Mats Lidstrom Sent: Thursday, February 26, 2004 4:24 AM To: dev...@li... Subject: Re: [Dev-C++] getting started creating a windows gui application If you're new to c++ you shouldn't start with creating windows and buttons. You should start picking up a good book about c++ programming and follow that. Window programming isn't "beginners level" so to speak. Dev-Cpp is just a graphical interface for the compiler and you can't actually draw the windows or components graphically. If you really need that you could look at "Visual C++" from Microsoft (http://msdn.microsoft.com/visualc/), but believe me - you're starting at the wrong end. /M ----- Original Message ----- From: Don Raikes <mailto:don...@or...> To: dev...@li... Sent: Thursday, February 26, 2004 4:06 AM Subject: [Dev-C++] getting started creating a windows gui application Hi all, I just installed dev-cpp 4.9.8, and want to get started creating a windows application. I was able to generate teh initial c++ application file via the wizard, but now how do I add controls to the window such as menus, buttons etc. are there any "simple" examples? I am a newbie with c/c++ programming so I'd like something pretty simple to start with. |
|
From: Mats L. <mat...@to...> - 2004-02-26 09:32:17
|
If you're new to c++ you shouldn't start with creating windows and = buttons. You should start picking up a good book about c++ programming = and follow that. Window programming isn't "beginners level" so to speak. Dev-Cpp is just a graphical interface for the compiler and you can't = actually draw the windows or components graphically. If you really need = that you could look at "Visual C++" from Microsoft = (http://msdn.microsoft.com/visualc/), but believe me - you're starting = at the wrong end. /M ----- Original Message -----=20 From: Don Raikes=20 To: dev...@li...=20 Sent: Thursday, February 26, 2004 4:06 AM Subject: [Dev-C++] getting started creating a windows gui application Hi all, I just installed dev-cpp 4.9.8, and want to get started creating a = windows application. I was able to generate teh initial c++ application file via the = wizard, but now how do I add controls to the window such as menus, = buttons etc. are there any "simple" examples? I am a newbie with c/c++ programming = so I'd like something pretty simple to start with. |
|
From: Vlada D. <dj...@im...> - 2004-02-26 08:53:35
|
----- Original Message ----- From: "Don Raikes" <don...@or...> To: <dev...@li...> Sent: Thursday, February 26, 2004 4:06 AM Subject: [Dev-C++] getting started creating a windows gui application >Hi all, >I just installed dev-cpp 4.9.8, and want to get started creating a windows application. > >I was able to generate teh initial c++ application file via the wizard, but now how do I add controls to the window >such as menus, buttons etc. > >are there any "simple" examples? I am a newbie with c/c++ programming so I'd like something pretty simple to start >with. In order to add controls to your windows, you need to edit the resource file. There's a good tutorial on windows programming at www.winprog.org . I f you are completely new to C/C++, maybe it's not such a good idea to start with Windows programming right away. You should first learn the basics using console, and then start with Windows. |