dev-cpp-users Mailing List for Dev-C++ (Page 245)
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: Hossein H. <ult...@em...> - 2004-02-29 12:18:47
|
Mike, As like as all of the recent messages I've posted to this list, sorry for this much late answer. I was too busy as this thread was going on, but I saved it till a time I can answer it, i.e. now! > You need to declare "it" as being of type iterator. So in the for > definition, you want: > > for (iterator it = myvec.begin(); it != myvec.end(); ++it) Although not wrong, but the principle of const-correctness tells us that "it" must be of type "cons_iterator" rather than just "iterator." > The iterator as assigned above is a pointer to the first element of the > vector. No, not necessarily! The types of vector<>::iterator, and vector<>::const_iterator are, as per the Standard, implementation-specific. That is, although they are most likely to be implemented using pure pointers, they are not needed to be so. In fact, they are some widely-used implementations of STL (such as STLPort) which do not implement the above stuff using pure pointers. Regards, --Hossein -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm |
|
From: Mats L. <mat...@to...> - 2004-02-29 11:58:35
|
You have program type settings under project options (Project / Project
Options / tab: General) You can select GUI, console, static lib or DLL
there. The other thing that pops up in my mind is that your DevCpp is
actually compiled for Windows so it has to be different from the Unix one.
The naming of those variables in the book wasn't very clever. I always name
my variables starting with something like "ml_" (my initials) or something
like that to avoid redeclarations. Do a global search and replace and change
LP to TCPL_LP :)
/M
From: "Kenneth P. Ruppel" <kpr...@op...>
> I have been working through Stroustrup's "The C++ Programming Language"
> Special Edition. I have run into a problemcompiling a program that
> Stroustrup says compiles and runs on his system, which I believe is a
> Unix system.
>
> The code (p.109) that doesn't compile is the following:
>
> #include <iostream>
> #include <string>
> #include <map>
> #include <cctype>
> using namespace std;
>
> // ENUM p.109
> enum Token_value{
> NAME, NUMBER, END,
> PLUS='+', MINUS='-=', MUL='*=', DIV='/',
> PRINT=';', ASSIGN='=', LP='(', RP=')'
>
> The error I get is the following:
>
> 'LP' redeclared as different kind of symbol
>
> This error comes from a statement in winnt.h, which is not included.
>
> The problem is, I have been to the C++ Learning newsgroup, and after
> letting them see that winnt.h is not included, etc., etc., they have
> left me with "there must be a switch in your application/IDE
> configuration that is trying to write a Windows program. You need to
> select configuration switches that produce a 'console' program in
> Windows or a DOS program."
>
> I am using Bloodshed 4.9.8.7, and I have never had to change the config
> to compile and run other programs that come up in a DOS window. And I
> have never changed the options in "Compiler Options". And also, the
> options that indicate trying to support C constructs, I selected "No",
> since I am trying to un-confuse myself and learn C++ only.
>
> Does anybody have any ideas why this error from winnt.h is appearing.
|
|
From: Emiliano <sky...@fa...> - 2004-02-29 08:19:54
|
Sorry but Outlook decided not to quote this morning... I'll try manually. >Sure, just compile the static version of the library, and recompile >the >exe. The symbols will be linked in. Please explain me what to do exactly. If I have understood, I need to put into my project the source files of the library too? I thought it was enough to put into the linker parameters the ".a/.lib" file... >> This is the way it works on other systems... >Well, on Linux, mostly dynamic libraries are used. (.so files) I know that, I LIKE shared stuff (libs, resources, memory and so on :)), and a lot. But for convenience reasons, now it would be MUCH better for me to have just a single executable and NO scattered files. I need to put into it just a couple of libs. Thanks for your attention, Emiliano |
|
From: Kenneth P. R. <kpr...@op...> - 2004-02-29 06:51:58
|
I have been working through Stroustrup's "The C++ Programming Language"
Special Edition. I have run into a problemcompiling a program that
Stroustrup says compiles and runs on his system, which I believe is a
Unix system.
The code (p.109) that doesn't compile is the following:
#include <iostream>
#include <string>
#include <map>
#include <cctype>
using namespace std;
// ENUM p.109
enum Token_value{
NAME, NUMBER, END,
PLUS='+', MINUS='-=', MUL='*=', DIV='/',
PRINT=';', ASSIGN='=', LP='(', RP=')'
The error I get is the following:
'LP' redeclared as different kind of symbol
This error comes from a statement in winnt.h, which is not included.
The problem is, I have been to the C++ Learning newsgroup, and after
letting them see that winnt.h is not included, etc., etc., they have
left me with "there must be a switch in your application/IDE
configuration that is trying to write a Windows program. You need to
select configuration switches that produce a 'console' program in
Windows or a DOS program."
I am using Bloodshed 4.9.8.7, and I have never had to change the config
to compile and run other programs that come up in a DOS window. And I
have never changed the options in "Compiler Options". And also, the
options that indicate trying to support C constructs, I selected "No",
since I am trying to un-confuse myself and learn C++ only.
Does anybody have any ideas why this error from winnt.h is appearing.
Ken
|
|
From: Per W. <pw...@ia...> - 2004-02-29 01:19:57
|
Yes, you can continue to cascade the pointers to pointers to... but with a
correctly written program you never need to since the goal of the program
is to either move the pointer or what the pointer points to.
/Per W
On Sat, 28 Feb 2004, David McKen wrote:
> Thanks,
>
> Just a question for future refrence but can the "pointer to" chain go
> infinitely?
> i.e.
> Does char *** x make a pointer-to-a-pointer-to-a-pointer-to-a-char ?
>
> Also refrences cannot be chained, right? That would be the logical
> AND
> operator anyway.
>
> ----- Original Message -----
> From: "Per Westermark" <pw...@ia...>
> To: "David McKen" <ci...@ya...>
> Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> Sent: Saturday, February 28, 2004 3:20 PM
> Subject: Re: [Dev-C++] Crash with macro to template conversion
>
>
> > Oops. Too quick answer :-)
> > With the following construct, the caller will get back the newly
> allocated
> > pointer:
> >
> > void alloc(char*& ptr) {
> > ptr = new char[10];
> > }
> >
> > int main() {
> > char *ptr = NULL;
> > printf("ptr = %p\n",ptr);
> > alloc(ptr);
> > printf("ptr = %p\n",ptr);
> > return 0;
> > }
> >
> > /Per W
> >
> > On Sat, 28 Feb 2004, David McKen wrote:
> >
> > > you apparently did not read the end of my message,
> > >
> > > I know how to create a pointer to a pointer (**) I haven't heard
> > > about a
> > > refrence to a pointer (&* ?), what is the syntax for such a
> variable?
> > >
> > > ----- Original Message -----
> > > From: "Per Westermark" <pw...@ia...>
> > > To: "David McKen" <ci...@ya...>
> > > Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> > > Sent: Saturday, February 28, 2004 5:27 AM
> > > Subject: Re: [Dev-C++] Crash with macro to template conversion
> > >
> > >
> > > > But you have not fixed the declaration of the ptr parameter
> yet.
> > > Any
> > > > allocations you make will behave ok inside the create()
> function,
> > > but the
> > > > caller will never get the value of the allocated pointer! You
> > > REALLY MUST
> > > > change del parameter declaration to either be a pointer to a
> > > pointer, or a
> > > > reference to a pointer!
> > > >
> > > > /Per W
> > > >
> > > > On Fri, 27 Feb 2004, David McKen wrote:
> > > >
> > > > > Sorry about that the correct definition is:
> > > > > template<class T>
> > > > > void create(T * ptr, int number, char * f_name = __FILE__,
> int
> > > l_num
> > > > > =
> > > > > __LINE__)
> > > > > {
> > > > > ptr = new T[number];
> > > > > if ( !ptr )
> > > > > {
> > > > > perror("malloc failure");
> > > > > fprintf( stderr, "Malloc failure @ %s:%d\n", f_name,
> l_num );
> > > > > abort();
> > > > > }
> > > > > }
> > > > >
> > > > > All the exception stuff was just trying to figure out if an
> error
> > > is
> > > > > even
> > > > > occuring.
> > > > >
> > > > > I am trying to keep to convention. The macro is not my code
> but
> > > code
> > > > > I am
> > > > > trying to replace. I am very tempted to change it but I also
> have
> > > > > RECREATE
> > > > > (wraps realloc()) and DESTROY (wraps free() ) which also need
> to
> > > be
> > > > > replaced. I could use macros to alter the function call but I
> am
> > > > > trying to
> > > > > remove all the macros I can (got some linked list macros to
> > > replace
> > > > > as well)
> > > > >
> > > > > So...How does one create a refrence to a pointer?
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Per Westermark" <pw...@ia...>
> > > > > To: "David McKen" <ci...@ya...>
> > > > > Cc: "Mailing List, Dev-Cpp"
> <dev...@li...>
> > > > > Sent: Friday, February 27, 2004 7:08 AM
> > > > > Subject: Re: [Dev-C++] Crash with macro to template
> conversion
> > > > >
> > > > >
> > > > > > 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
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > -------------------------------------------------------
> > > > > > 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
> > > > >
> > > > >
> > > > > __________________________________
> > > > > 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
> > > > >
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > 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
> > >
> > >
> > > __________________________________
> > > 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
> > >
> >
> >
> >
> > -------------------------------------------------------
> > 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
>
>
> __________________________________
> 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: <or...@vp...> - 2004-02-29 01:00:54
|
Emiliano wrote: > Many thanks: I had to link with "-ljpeg", now it seems to work. >=20 > BUT, do I _always_ need to have external dlls coming with my app? Or is > there a way to include libraries into the executable? Sure, just compile the static version of the library, and recompile the=20 exe. The symbols will be linked in. > This is the way it works on other systems... Well, on Linux, mostly dynamic libraries are used. (.so files) -- Greetings, Bal=E1zs |
|
From: David M. <ci...@ya...> - 2004-02-29 00:57:24
|
Thanks,
Just a question for future refrence but can the "pointer to" chain go
infinitely?
i.e.
Does char *** x make a pointer-to-a-pointer-to-a-pointer-to-a-char ?
Also refrences cannot be chained, right? That would be the logical
AND
operator anyway.
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "David McKen" <ci...@ya...>
Cc: "Mailing List, Dev-Cpp" <dev...@li...>
Sent: Saturday, February 28, 2004 3:20 PM
Subject: Re: [Dev-C++] Crash with macro to template conversion
> Oops. Too quick answer :-)
> With the following construct, the caller will get back the newly
allocated
> pointer:
>
> void alloc(char*& ptr) {
> ptr = new char[10];
> }
>
> int main() {
> char *ptr = NULL;
> printf("ptr = %p\n",ptr);
> alloc(ptr);
> printf("ptr = %p\n",ptr);
> return 0;
> }
>
> /Per W
>
> On Sat, 28 Feb 2004, David McKen wrote:
>
> > you apparently did not read the end of my message,
> >
> > I know how to create a pointer to a pointer (**) I haven't heard
> > about a
> > refrence to a pointer (&* ?), what is the syntax for such a
variable?
> >
> > ----- Original Message -----
> > From: "Per Westermark" <pw...@ia...>
> > To: "David McKen" <ci...@ya...>
> > Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> > Sent: Saturday, February 28, 2004 5:27 AM
> > Subject: Re: [Dev-C++] Crash with macro to template conversion
> >
> >
> > > But you have not fixed the declaration of the ptr parameter
yet.
> > Any
> > > allocations you make will behave ok inside the create()
function,
> > but the
> > > caller will never get the value of the allocated pointer! You
> > REALLY MUST
> > > change del parameter declaration to either be a pointer to a
> > pointer, or a
> > > reference to a pointer!
> > >
> > > /Per W
> > >
> > > On Fri, 27 Feb 2004, David McKen wrote:
> > >
> > > > Sorry about that the correct definition is:
> > > > template<class T>
> > > > void create(T * ptr, int number, char * f_name = __FILE__,
int
> > l_num
> > > > =
> > > > __LINE__)
> > > > {
> > > > ptr = new T[number];
> > > > if ( !ptr )
> > > > {
> > > > perror("malloc failure");
> > > > fprintf( stderr, "Malloc failure @ %s:%d\n", f_name,
l_num );
> > > > abort();
> > > > }
> > > > }
> > > >
> > > > All the exception stuff was just trying to figure out if an
error
> > is
> > > > even
> > > > occuring.
> > > >
> > > > I am trying to keep to convention. The macro is not my code
but
> > code
> > > > I am
> > > > trying to replace. I am very tempted to change it but I also
have
> > > > RECREATE
> > > > (wraps realloc()) and DESTROY (wraps free() ) which also need
to
> > be
> > > > replaced. I could use macros to alter the function call but I
am
> > > > trying to
> > > > remove all the macros I can (got some linked list macros to
> > replace
> > > > as well)
> > > >
> > > > So...How does one create a refrence to a pointer?
> > > >
> > > > ----- Original Message -----
> > > > From: "Per Westermark" <pw...@ia...>
> > > > To: "David McKen" <ci...@ya...>
> > > > Cc: "Mailing List, Dev-Cpp"
<dev...@li...>
> > > > Sent: Friday, February 27, 2004 7:08 AM
> > > > Subject: Re: [Dev-C++] Crash with macro to template
conversion
> > > >
> > > >
> > > > > 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
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > -------------------------------------------------------
> > > > > 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
> > > >
> > > >
> > > > __________________________________
> > > > 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
> > > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > 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
> >
> >
> > __________________________________
> > 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
> >
>
>
>
> -------------------------------------------------------
> 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
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
|
|
From: Emiliano <sky...@fa...> - 2004-02-29 00:12:26
|
Many thanks: I had to link with "-ljpeg", now it seems to work. BUT, do I _always_ need to have external dlls coming with my app? Or is there a way to include libraries into the executable? This is the way it works on other systems... Emiliano ----- Original Message ----- From: "Daniel K. O." <dan...@ya...> To: "Emiliano" <sky...@fa...> Cc: <dev...@li...> Sent: Sunday, February 29, 2004 12:44 AM Subject: Re: [Dev-C++] Another one with static libraries. > Emiliano wrote: > > >Does windows support static libraries? > > > >I include jpeg.lib (or any other .lib/.a file) into my project, but, when > >executing, windows complains about "jpeglib6b.dll" missing. > > > >This is not a big problem with other libraries coming with a .dll file, but > >jpeglib misses that one, and I don't want to compile it from scratch... at > >least would avoid that :) > > > > > > Some libs - like the libjpeg - have different dll versions for the same > thing. The lib you have is for another dll compilation. > I had a problem recently with libFLAC; the lib was exporting some MD5 > symbols, that were conflicting with the program. So I linked directly to > the libFLAC.dll - yes, MinGW can also link directly to the .dll, just > add it to the linker options. > > Or, if it doesn't work, go to gnuwin32 page and download the libjpeg > from them. > > > > Daniel K. O. > > > > ------------------------------------------------------- > 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: Daniel K. O. <dan...@ya...> - 2004-02-28 23:55:40
|
Emiliano wrote: >Does windows support static libraries? > >I include jpeg.lib (or any other .lib/.a file) into my project, but, when >executing, windows complains about "jpeglib6b.dll" missing. > >This is not a big problem with other libraries coming with a .dll file, but >jpeglib misses that one, and I don't want to compile it from scratch... at >least would avoid that :) > > Some libs - like the libjpeg - have different dll versions for the same thing. The lib you have is for another dll compilation. I had a problem recently with libFLAC; the lib was exporting some MD5 symbols, that were conflicting with the program. So I linked directly to the libFLAC.dll - yes, MinGW can also link directly to the .dll, just add it to the linker options. Or, if it doesn't work, go to gnuwin32 page and download the libjpeg from them. Daniel K. O. |
|
From: Emiliano <sky...@fa...> - 2004-02-28 23:46:09
|
Does windows support static libraries? I include jpeg.lib (or any other .lib/.a file) into my project, but, when executing, windows complains about "jpeglib6b.dll" missing. This is not a big problem with other libraries coming with a .dll file, but jpeglib misses that one, and I don't want to compile it from scratch... at least would avoid that :) regards, Emiliano |
|
From: Per W. <pw...@ia...> - 2004-02-28 23:31:33
|
Oops. Too quick answer :-)
With the following construct, the caller will get back the newly allocated
pointer:
void alloc(char*& ptr) {
ptr = new char[10];
}
int main() {
char *ptr = NULL;
printf("ptr = %p\n",ptr);
alloc(ptr);
printf("ptr = %p\n",ptr);
return 0;
}
/Per W
On Sat, 28 Feb 2004, David McKen wrote:
> you apparently did not read the end of my message,
>
> I know how to create a pointer to a pointer (**) I haven't heard
> about a
> refrence to a pointer (&* ?), what is the syntax for such a variable?
>
> ----- Original Message -----
> From: "Per Westermark" <pw...@ia...>
> To: "David McKen" <ci...@ya...>
> Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> Sent: Saturday, February 28, 2004 5:27 AM
> Subject: Re: [Dev-C++] Crash with macro to template conversion
>
>
> > But you have not fixed the declaration of the ptr parameter yet.
> Any
> > allocations you make will behave ok inside the create() function,
> but the
> > caller will never get the value of the allocated pointer! You
> REALLY MUST
> > change del parameter declaration to either be a pointer to a
> pointer, or a
> > reference to a pointer!
> >
> > /Per W
> >
> > On Fri, 27 Feb 2004, David McKen wrote:
> >
> > > Sorry about that the correct definition is:
> > > template<class T>
> > > void create(T * ptr, int number, char * f_name = __FILE__, int
> l_num
> > > =
> > > __LINE__)
> > > {
> > > ptr = new T[number];
> > > if ( !ptr )
> > > {
> > > perror("malloc failure");
> > > fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
> > > abort();
> > > }
> > > }
> > >
> > > All the exception stuff was just trying to figure out if an error
> is
> > > even
> > > occuring.
> > >
> > > I am trying to keep to convention. The macro is not my code but
> code
> > > I am
> > > trying to replace. I am very tempted to change it but I also have
> > > RECREATE
> > > (wraps realloc()) and DESTROY (wraps free() ) which also need to
> be
> > > replaced. I could use macros to alter the function call but I am
> > > trying to
> > > remove all the macros I can (got some linked list macros to
> replace
> > > as well)
> > >
> > > So...How does one create a refrence to a pointer?
> > >
> > > ----- Original Message -----
> > > From: "Per Westermark" <pw...@ia...>
> > > To: "David McKen" <ci...@ya...>
> > > Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> > > Sent: Friday, February 27, 2004 7:08 AM
> > > Subject: Re: [Dev-C++] Crash with macro to template conversion
> > >
> > >
> > > > 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
> > > > >
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > 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
> > >
> > >
> > > __________________________________
> > > 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
> > >
> >
> >
> >
> > -------------------------------------------------------
> > 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
>
>
> __________________________________
> 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: David M. <ci...@ya...> - 2004-02-28 23:22:11
|
you apparently did not read the end of my message,
I know how to create a pointer to a pointer (**) I haven't heard
about a
refrence to a pointer (&* ?), what is the syntax for such a variable?
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "David McKen" <ci...@ya...>
Cc: "Mailing List, Dev-Cpp" <dev...@li...>
Sent: Saturday, February 28, 2004 5:27 AM
Subject: Re: [Dev-C++] Crash with macro to template conversion
> But you have not fixed the declaration of the ptr parameter yet.
Any
> allocations you make will behave ok inside the create() function,
but the
> caller will never get the value of the allocated pointer! You
REALLY MUST
> change del parameter declaration to either be a pointer to a
pointer, or a
> reference to a pointer!
>
> /Per W
>
> On Fri, 27 Feb 2004, David McKen wrote:
>
> > Sorry about that the correct definition is:
> > template<class T>
> > void create(T * ptr, int number, char * f_name = __FILE__, int
l_num
> > =
> > __LINE__)
> > {
> > ptr = new T[number];
> > if ( !ptr )
> > {
> > perror("malloc failure");
> > fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
> > abort();
> > }
> > }
> >
> > All the exception stuff was just trying to figure out if an error
is
> > even
> > occuring.
> >
> > I am trying to keep to convention. The macro is not my code but
code
> > I am
> > trying to replace. I am very tempted to change it but I also have
> > RECREATE
> > (wraps realloc()) and DESTROY (wraps free() ) which also need to
be
> > replaced. I could use macros to alter the function call but I am
> > trying to
> > remove all the macros I can (got some linked list macros to
replace
> > as well)
> >
> > So...How does one create a refrence to a pointer?
> >
> > ----- Original Message -----
> > From: "Per Westermark" <pw...@ia...>
> > To: "David McKen" <ci...@ya...>
> > Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> > Sent: Friday, February 27, 2004 7:08 AM
> > Subject: Re: [Dev-C++] Crash with macro to template conversion
> >
> >
> > > 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
> > > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > 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
> >
> >
> > __________________________________
> > 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
> >
>
>
>
> -------------------------------------------------------
> 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
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
|
|
From: Emiliano <sky...@fa...> - 2004-02-28 22:09:38
|
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "Emiliano" <sky...@fa...>
Cc: <dev...@li...>
Sent: Saturday, February 28, 2004 10:11 PM
Subject: Re: [Dev-C++] Problem with jpeg.library
> The library is written in C, and your program in C++.
>
> do:
>
> extern "C" {
> #include "jpeglib.h"
> }
>
> to inform the compiler that it should look for the jpeg functions using
> the C calling convention, and not try to name-mangle the symbols.
Great!! I had tried to set "compile as C" the only file using jpeg lib and
it didn't work :)
with that directive, it worked at once!
thanks again,
Emiliano
|
|
From: Per W. <pw...@ia...> - 2004-02-28 21:22:28
|
The library is written in C, and your program in C++.
do:
extern "C" {
#include "jpeglib.h"
}
to inform the compiler that it should look for the jpeg functions using
the C calling convention, and not try to name-mangle the symbols.
/Per W
On Sat, 28 Feb 2004, Emiliano wrote:
> It won't see any function, ie I get errors like this one:
>
>
> [Linker error] undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
>
>
>
> I have also included in the linker tab "jpeg.lib" and "libjpeg.a", both
> alone and together, but it won't change.
>
> Do I need to do something else?
>
> thanks,
> Emiliano
>
>
>
> -------------------------------------------------------
> 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-28 20:18:29
|
It won't see any function, ie I get errors like this one: [Linker error] undefined reference to `jpeg_std_error(jpeg_error_mgr*)' I have also included in the linker tab "jpeg.lib" and "libjpeg.a", both alone and together, but it won't change. Do I need to do something else? thanks, Emiliano |
|
From: Per W. <pw...@ia...> - 2004-02-28 13:38:26
|
But you have not fixed the declaration of the ptr parameter yet. Any
allocations you make will behave ok inside the create() function, but the
caller will never get the value of the allocated pointer! You REALLY MUST
change del parameter declaration to either be a pointer to a pointer, or a
reference to a pointer!
/Per W
On Fri, 27 Feb 2004, David McKen wrote:
> Sorry about that the correct definition is:
> template<class T>
> void create(T * ptr, int number, char * f_name = __FILE__, int l_num
> =
> __LINE__)
> {
> ptr = new T[number];
> if ( !ptr )
> {
> perror("malloc failure");
> fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
> abort();
> }
> }
>
> All the exception stuff was just trying to figure out if an error is
> even
> occuring.
>
> I am trying to keep to convention. The macro is not my code but code
> I am
> trying to replace. I am very tempted to change it but I also have
> RECREATE
> (wraps realloc()) and DESTROY (wraps free() ) which also need to be
> replaced. I could use macros to alter the function call but I am
> trying to
> remove all the macros I can (got some linked list macros to replace
> as well)
>
> So...How does one create a refrence to a pointer?
>
> ----- Original Message -----
> From: "Per Westermark" <pw...@ia...>
> To: "David McKen" <ci...@ya...>
> Cc: "Mailing List, Dev-Cpp" <dev...@li...>
> Sent: Friday, February 27, 2004 7:08 AM
> Subject: Re: [Dev-C++] Crash with macro to template conversion
>
>
> > 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
> > >
> >
> >
> >
> > -------------------------------------------------------
> > 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
>
>
> __________________________________
> 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: <jab...@ta...> - 2004-02-28 12:46:01
|
What I am trying to do is to put a bitmap (a logo) in a "About Dialog Box". The problem is that the logo is shown, but the program freezes. I hope is clear now. Jorge > > From: oladipo olayiwola <ola...@ya...> > Date: 2004/02/27 Fri PM 10:19:11 EST > To: jab...@ta... > Subject: Re: [Dev-C++] displaying bitmap in a dialog box > > > To start with, I really don't know what you are trying to achieve, maybe you should be more specific so I can render any little advice I can . Hope to hear from you > > > --------------------------------- > Do you Yahoo!? > Get better spam protection with Yahoo! Mail > |
|
From: David M. <ci...@ya...> - 2004-02-28 06:06:24
|
Sorry about that the correct definition is:
template<class T>
void create(T * ptr, int number, char * f_name = __FILE__, int l_num
=
__LINE__)
{
ptr = new T[number];
if ( !ptr )
{
perror("malloc failure");
fprintf( stderr, "Malloc failure @ %s:%d\n", f_name, l_num );
abort();
}
}
All the exception stuff was just trying to figure out if an error is
even
occuring.
I am trying to keep to convention. The macro is not my code but code
I am
trying to replace. I am very tempted to change it but I also have
RECREATE
(wraps realloc()) and DESTROY (wraps free() ) which also need to be
replaced. I could use macros to alter the function call but I am
trying to
remove all the macros I can (got some linked list macros to replace
as well)
So...How does one create a refrence to a pointer?
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "David McKen" <ci...@ya...>
Cc: "Mailing List, Dev-Cpp" <dev...@li...>
Sent: Friday, February 27, 2004 7:08 AM
Subject: Re: [Dev-C++] Crash with macro to template conversion
> 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
> >
>
>
>
> -------------------------------------------------------
> 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
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
|
|
From: <jab...@ta...> - 2004-02-28 03:03:58
|
I'm trying to put a bitmap in a dialog box. It's not working: a) it freezes, b) if I comment the loadimage line and move the box, it grays up the background without repainting. I'm using win 98. Here is the code:
.....
case WM_PAINT:
{
HBITMAP hbmSail;
BITMAP bm;
int X, Y;
hbmSail = (HBITMAP) LoadImage(GetModuleHandle (NULL), // hinst is global
MAKEINTRESOURCE(5),
IMAGE_BITMAP,
0,
0,
0);
if(!hbmSail){
MessageBox(hwnd, "Load of resources failed.", "Error",
MB_OK | MB_ICONEXCLAMATION);
return -1;
}
GetObject(hbmSail, sizeof(bm), &bm);
X = 20;
Y = 20;
HDC hdcMemory;
HDC hdc;
hdc=GetDC(hwnd);
hdcMemory = CreateCompatibleDC(hdc);
SelectObject(hdcMemory, hbmSail);
BitBlt(hdc, X, Y, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
DeleteDC(hdcMemory);
ReleaseDC (hwnd,hdc);
}
......
What am I doing wrong? or better, am I doing anything right?
Thanks for the help!!!
Jorge
|
|
From: Can C. <can...@ho...> - 2004-02-28 01:11:03
|
I've got 4.9.8.7 and updater doesn't work now.It doesn't conect to server .It says 'Please try another server'.But there is only one server on the dropdown server list . How can I fix this problem ? Thanks Can Canova ----------------- _________________________________________________________________ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp |
|
From: John M. <j....@ch...> - 2004-02-27 20:18:15
|
Hi,
I have a strange problem which i am trying to solve for days now. I
really hope you can help me.
I am writing a program for Win98, 2000 and XP that reads text and
filenames from a plain file. The filenames correspond to pictures on the
local disc. The user can browse through the database and can view the
images, set them as wallpaper and print them.
On windows 2000 and XP the viewing, wallpaper and printing works fine.
In Windows 98 the viewing and wallpaper works, but when it comes to
printing only plank pages are produced.
I use the following code for full-page printing of a bitmap :
void Printer::DrawPage(wxDC *dc) {
int w, h;
float maxX = 1767;
float maxY = 2500;
float marginX = 10;
float marginY = 10;
maxX += (2*marginX);
maxY += (2*marginY);
dc->GetSize(&w, &h);
float scaleX=(float)(w/maxX);
float scaleY=(float)(h/maxY);
// Use x or y scaling factor, whichever fits on the DC
float actualScale = wxMin(scaleX,scaleY);
float posX = (float)((w - (maxX*actualScale))/2.0);
float posY = (float)((h - (maxY*actualScale))/2.0);
dc->SetUserScale(actualScale, actualScale);
dc->SetDeviceOrigin( (long)posX, (long)posY );
dc->DrawBitmap( *afbeelding, 0, 0, FALSE );
}
This code works in Win2000, and WinXP but NOT in Win98. When i add
DrawText the text is printed, the bitmap still isnot.
Kind regards,
John Melet
|
|
From: Emiliano <sky...@fa...> - 2004-02-27 19:45:22
|
----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Emiliano" <sky...@fa...> Cc: <dev...@li...> Sent: Friday, February 27, 2004 8:18 PM Subject: Re: [Dev-C++] WinAPI help... > Happy to be able to help :-) > > About the use of dynamic speed in the program. In case the program has > lost a lot of time, it might be an idea to have the update code run in a > while loop and perform multiple steps before next redraw. That way the > movement in each update step is still small enough that you don't get any > extra problems with collision detections. Good idea... now it only remains the key problem... the window procedure gets the message (WK_KEYDOWN), the PostQuitMessage() is called, even multiple times, but "GetMessage()" won't notice it at all!! Maybe too many messages waiting?? but the WM_QUIT should be dealt with sooner or later. Or is it lost (tragic) or bypassed?? Emiliano |
|
From: Per W. <pw...@ia...> - 2004-02-27 19:29:15
|
Happy to be able to help :-) About the use of dynamic speed in the program. In case the program has lost a lot of time, it might be an idea to have the update code run in a while loop and perform multiple steps before next redraw. That way the movement in each update step is still small enough that you don't get any extra problems with collision detections. /Per W On Fri, 27 Feb 2004, Emiliano wrote: > > ----- Original Message ----- > From: "Per Westermark" <pw...@ia...> > To: "Emiliano" <sky...@fa...> > Cc: <dev...@li...> > Sent: Friday, February 27, 2004 6:13 PM > Subject: Re: [Dev-C++] WinAPI help... > > > > I don't think that you should run run your drawing code in > > THREAD_PRIORITY_IDLE - it should be THREAD_PRIORITY_BELOW_NORMAL or > > THREAD_PRIORITY_LOWEST, since you don't want any background processing on > > the machine to starve the drawing code. > > Yes. I put that just for testing, in the first tests.. > > > Why don't you remove the timer thread, since the work may easily be > > performed in the drawing thread? I don't have the exact specifications > > available right now, but for WinNT, Win2k, WinXP... you may also use > > waitable timers to implement delays. > > Thank you!! I found that CreateWT() works quite better! Now I get 50 fps > with a 20 msecs period, and 94 fps with 10 (well, that difference, about ~ > 0,5 msecs is accettable in a multitasking environment). > > Anyway, I DO need to keep drawing and updating as separate tasks. If I don't > do this, I risk (on crowded and slow scenes) that the update won't take > place (since the task is busy drawing the scene). This is right what happens > with the Glut library, which has some timer functions that simply use the > crappy "SetTimer()" (or similar). So, if you have a long task to do, the > timer is not seen at all (you have to restart the "GetMessage()" loop, > despite what the WinAPI docs say!!). > > The simplest method is probably to add to all movements, a multiply factor > that depends on time spent between two frames. Thus, the more time passes, > the more speed objects must have in the next frame. I think I'll implement > this later on, since I've tried it now and it would make collision detection > harder (ie: doesn't work as expected :D). > > Anyhow, I still LOOSE escape key presses sometimes... this doesn't happen > with a single thread, why?? :((( > > > See CreateWaitableTimer, SetWaitableTimer, WaitForSingleObject, > > WaitForMultipleObjects... > > > When your application is minimized, you really should teach your drawing > > thread to just sleep. > > Yes this can be easily implemented. Anyway, it could be a feature (maybe one > wants the rendering to go on while the app is minimized away). > > Thanks again, your help is really worth a lot! :) > > Emiliano > > > > ------------------------------------------------------- > 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 19:10:40
|
----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Emiliano" <sky...@fa...> Cc: <dev...@li...> Sent: Friday, February 27, 2004 6:13 PM Subject: Re: [Dev-C++] WinAPI help... > I don't think that you should run run your drawing code in > THREAD_PRIORITY_IDLE - it should be THREAD_PRIORITY_BELOW_NORMAL or > THREAD_PRIORITY_LOWEST, since you don't want any background processing on > the machine to starve the drawing code. Yes. I put that just for testing, in the first tests.. > Why don't you remove the timer thread, since the work may easily be > performed in the drawing thread? I don't have the exact specifications > available right now, but for WinNT, Win2k, WinXP... you may also use > waitable timers to implement delays. Thank you!! I found that CreateWT() works quite better! Now I get 50 fps with a 20 msecs period, and 94 fps with 10 (well, that difference, about ~ 0,5 msecs is accettable in a multitasking environment). Anyway, I DO need to keep drawing and updating as separate tasks. If I don't do this, I risk (on crowded and slow scenes) that the update won't take place (since the task is busy drawing the scene). This is right what happens with the Glut library, which has some timer functions that simply use the crappy "SetTimer()" (or similar). So, if you have a long task to do, the timer is not seen at all (you have to restart the "GetMessage()" loop, despite what the WinAPI docs say!!). The simplest method is probably to add to all movements, a multiply factor that depends on time spent between two frames. Thus, the more time passes, the more speed objects must have in the next frame. I think I'll implement this later on, since I've tried it now and it would make collision detection harder (ie: doesn't work as expected :D). Anyhow, I still LOOSE escape key presses sometimes... this doesn't happen with a single thread, why?? :((( > See CreateWaitableTimer, SetWaitableTimer, WaitForSingleObject, > WaitForMultipleObjects... > When your application is minimized, you really should teach your drawing > thread to just sleep. Yes this can be easily implemented. Anyway, it could be a feature (maybe one wants the rendering to go on while the app is minimized away). Thanks again, your help is really worth a lot! :) Emiliano |
|
From: Per W. <pw...@ia...> - 2004-02-27 17:24:20
|
I don't think that you should run run your drawing code in THREAD_PRIORITY_IDLE - it should be THREAD_PRIORITY_BELOW_NORMAL or THREAD_PRIORITY_LOWEST, since you don't want any background processing on the machine to starve the drawing code. Why don't you remove the timer thread, since the work may easily be performed in the drawing thread? I don't have the exact specifications available right now, but for WinNT, Win2k, WinXP... you may also use waitable timers to implement delays. See CreateWaitableTimer, SetWaitableTimer, WaitForSingleObject, WaitForMultipleObjects... When your application is minimized, you really should teach your drawing thread to just sleep. /Per W On Fri, 27 Feb 2004, Emiliano wrote: > > 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 > > > > ------------------------------------------------------- > 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 > |