Thread: [GD-Linux] ANSI/ISO C++
Brought to you by:
vexxed72
From: Matt D. <ma...@co...> - 2001-12-11 09:38:41
|
Hi, Is there any free compilers for Linux that supports the full ANSI/ISO C++ language - which includes template template parameters and partial template specialisation. Does GCC support them yet? I need a compiler for Windows as well. Borland C++ 5.5 seems to do the job but I've had no luck making it work with the Turbo Debugger. Perhaps someone can provide me with help there? BTW, does anyone know whats happened to the SWENG mailing list. I've sent some messages out but I haven't received any. Is it down? Best regards, Matt Davies Programmer, Confounding Factor ma...@co... www.confounding-factor.com |
From: Daniel V. <vo...@ep...> - 2001-12-11 10:06:55
|
None of the commercial compilers out there supports the full range of the ISO C++ Standard though on either the sweng or algorithm list someone posted a list of "research" compilers that claim to be fully compliant. gcc 3.0 seems to have okay template support though I can't really tell as we hit a regression with gcc >= 2.96. You might try Intel's C++ compiler - it's not free for commercial use but I think you can use it for free if you are student or something like that. For a personal project it might be worth looking up the details as the compiler is $400 otherwise IIRC. If it's for real (time==money) use it's worth every penny as it compiles code roughly three times faster than gcc :) On Windows MSVC is free IIRC as long as you are a student or for non commercial use (as above I only vaguely remember the terms) though they only provide you with access to a non optimizing version of the compiler. MSVC has a nice IDE and debugger so you might want to give that a try. BTW, cross platformness and nifty template tricks are usually mutually exclusive - at least in my experience. Michael Vance @ TreyArch should be able to tell a lot of horror stories ;) -- Daniel, Epic Games Inc. -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Matt Davies Sent: Tuesday, December 11, 2001 4:36 AM To: gam...@li... Subject: [GD-Linux] ANSI/ISO C++ Hi, Is there any free compilers for Linux that supports the full ANSI/ISO C++ language - which includes template template parameters and partial template specialisation. Does GCC support them yet? I need a compiler for Windows as well. Borland C++ 5.5 seems to do the job but I've had no luck making it work with the Turbo Debugger. Perhaps someone can provide me with help there? BTW, does anyone know whats happened to the SWENG mailing list. I've sent some messages out but I haven't received any. Is it down? Best regards, Matt Davies Programmer, Confounding Factor ma...@co... www.confounding-factor.com |
From: Timothee B. <tt...@id...> - 2001-12-11 10:22:01
|
Yup .. never go too far into C++ stuff if you want to be cross-platform .. from my experience STL is already the limit :-) TTimo On Tue, 11 Dec 2001 05:02:49 -0500 "Daniel Vogel" <vo...@ep...> wrote: > None of the commercial compilers out there supports the full range of the > ISO C++ Standard though on either the sweng or algorithm list someone posted > a list of "research" compilers that claim to be fully compliant. > > gcc 3.0 seems to have okay template support though I can't really tell as we > hit a regression with gcc >= 2.96. You might try Intel's C++ compiler - it's > not free for commercial use but I think you can use it for free if you are > student or something like that. For a personal project it might be worth > looking up the details as the compiler is $400 otherwise IIRC. If it's for > real (time==money) use it's worth every penny as it compiles code roughly > three times faster than gcc :) > > On Windows MSVC is free IIRC as long as you are a student or for non > commercial use (as above I only vaguely remember the terms) though they only > provide you with access to a non optimizing version of the compiler. MSVC > has a nice IDE and debugger so you might want to give that a try. > > BTW, cross platformness and nifty template tricks are usually mutually > exclusive - at least in my experience. Michael Vance @ TreyArch should be > able to tell a lot of horror stories ;) > > -- Daniel, Epic Games Inc. > > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of Matt > Davies > Sent: Tuesday, December 11, 2001 4:36 AM > To: gam...@li... > Subject: [GD-Linux] ANSI/ISO C++ > > > Hi, > > Is there any free compilers for Linux that supports the full ANSI/ISO C++ > language - which includes template template parameters and partial template > specialisation. Does GCC support them yet? I need a compiler for Windows > as well. Borland C++ 5.5 seems to do the job but I've had no luck making it > work with the Turbo Debugger. Perhaps someone can provide me with help > there? > > BTW, does anyone know whats happened to the SWENG mailing list. I've sent > some messages out but I haven't received any. Is it down? > > Best regards, > > > Matt Davies > Programmer, Confounding Factor > ma...@co... > www.confounding-factor.com > > > _______________________________________________ > Gamedevlists-linux mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-linux > |
From: Matt D. <ma...@co...> - 2001-12-11 13:40:46
|
I would like to use the techniques used in Modern C++ Design and the Loki library. This is however impossible as MSVC (my only current compiler) does not support partial template specialisation or template template parameters (when are they going to get their act together on this). I hoped that perhaps GCC (on Linux) would support templates properly and I will try out version 3.0 - thanks. As for Windows I've tried out Borland C++ 5.5 which handles them nicely except I cannot use its debugger with any executable that I create. Could someone let me known how this is done. I plan to implement my code on Linux when I install it. I do have the Code Fusion compiler which I bought 2 years ago which is GCC with help from Intel. I am hoping that it has decent template support. But I doubt it. Is the free GCC not that efficient at optimising then? I would like to take this conversation to SWENG but it seems to be down and I haven't heard a peep from it for a few days now. I am hoping that a few on this list subscribe to SWENG so please forgive me when I ask this question: Has anyone converted the LOKI library to not use partial template specialisation so that I can compile it under MSVC? Cheers, Matt Davies Programmer, Confounding Factor ma...@co... www.confounding-factor.com -----Original Message----- From: Daniel Vogel [mailto:vo...@ep...] Sent: 11 December 2001 10:03 To: Matt Davies; gam...@li... Subject: RE: [GD-Linux] ANSI/ISO C++ None of the commercial compilers out there supports the full range of the ISO C++ Standard though on either the sweng or algorithm list someone posted a list of "research" compilers that claim to be fully compliant. gcc 3.0 seems to have okay template support though I can't really tell as we hit a regression with gcc >= 2.96. You might try Intel's C++ compiler - it's not free for commercial use but I think you can use it for free if you are student or something like that. For a personal project it might be worth looking up the details as the compiler is $400 otherwise IIRC. If it's for real (time==money) use it's worth every penny as it compiles code roughly three times faster than gcc :) On Windows MSVC is free IIRC as long as you are a student or for non commercial use (as above I only vaguely remember the terms) though they only provide you with access to a non optimizing version of the compiler. MSVC has a nice IDE and debugger so you might want to give that a try. BTW, cross platformness and nifty template tricks are usually mutually exclusive - at least in my experience. Michael Vance @ TreyArch should be able to tell a lot of horror stories ;) -- Daniel, Epic Games Inc. -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Matt Davies Sent: Tuesday, December 11, 2001 4:36 AM To: gam...@li... Subject: [GD-Linux] ANSI/ISO C++ Hi, Is there any free compilers for Linux that supports the full ANSI/ISO C++ language - which includes template template parameters and partial template specialisation. Does GCC support them yet? I need a compiler for Windows as well. Borland C++ 5.5 seems to do the job but I've had no luck making it work with the Turbo Debugger. Perhaps someone can provide me with help there? BTW, does anyone know whats happened to the SWENG mailing list. I've sent some messages out but I haven't received any. Is it down? Best regards, Matt Davies Programmer, Confounding Factor ma...@co... www.confounding-factor.com |
From: D. S. <st...@id...> - 2001-12-11 16:09:32
|
Matt Davies wrote: > > I would like to use the techniques used in Modern C++ Design and the Loki > library. This is however impossible as MSVC (my only current compiler) does > not support partial template specialisation or template template parameters > (when are they going to get their act together on this). > > I hoped that perhaps GCC (on Linux) would support templates properly and I > will try out version 3.0 - thanks. As for Windows I've tried out Borland > C++ 5.5 which handles them nicely except I cannot use its debugger with any > executable that I create. Could someone let me known how this is done. g++ 2.96 of redhat supports partial specialization. The 3.x series does. I don't know if the older 2.91.x supports it or not. Even if older ones support partial specialization, I'd recommend going newer g++ due to much better STL support (this is probably due more to packaging than to the compiler itself, but I'm not sure). IMHO, the template support on 2.96+ is really nice for g++, the only real complaint I know of there is that lots of templates results in long compile times. I don't know what LOKI uses, I suggest you just give it a try. As someone else mentioned, there is no such thing as a fully ANSI/ISO C++ compiler. If you are going to distribute source code, you probably want what you expect the end user to compile on; if sending binary code, probably whatever gives you the best code and most coding quality. D. Stimits, st...@id... > > I plan to implement my code on Linux when I install it. I do have the Code > Fusion compiler which I bought 2 years ago which is GCC with help from > Intel. I am hoping that it has decent template support. But I doubt it. > Is the free GCC not that efficient at optimising then? > > I would like to take this conversation to SWENG but it seems to be down and > I haven't heard a peep from it for a few days now. I am hoping that a few > on this list subscribe to SWENG so please forgive me when I ask this > question: > > Has anyone converted the LOKI library to not use partial template > specialisation so that I can compile it under MSVC? > > Cheers, > > Matt Davies > Programmer, Confounding Factor > ma...@co... > www.confounding-factor.com > > -----Original Message----- > From: Daniel Vogel [mailto:vo...@ep...] > Sent: 11 December 2001 10:03 > To: Matt Davies; gam...@li... > Subject: RE: [GD-Linux] ANSI/ISO C++ > > None of the commercial compilers out there supports the full range of the > ISO C++ Standard though on either the sweng or algorithm list someone posted > a list of "research" compilers that claim to be fully compliant. > > gcc 3.0 seems to have okay template support though I can't really tell as we > hit a regression with gcc >= 2.96. You might try Intel's C++ compiler - it's > not free for commercial use but I think you can use it for free if you are > student or something like that. For a personal project it might be worth > looking up the details as the compiler is $400 otherwise IIRC. If it's for > real (time==money) use it's worth every penny as it compiles code roughly > three times faster than gcc :) > > On Windows MSVC is free IIRC as long as you are a student or for non > commercial use (as above I only vaguely remember the terms) though they only > provide you with access to a non optimizing version of the compiler. MSVC > has a nice IDE and debugger so you might want to give that a try. > > BTW, cross platformness and nifty template tricks are usually mutually > exclusive - at least in my experience. Michael Vance @ TreyArch should be > able to tell a lot of horror stories ;) > > -- Daniel, Epic Games Inc. > > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of Matt > Davies > Sent: Tuesday, December 11, 2001 4:36 AM > To: gam...@li... > Subject: [GD-Linux] ANSI/ISO C++ > > Hi, > > Is there any free compilers for Linux that supports the full ANSI/ISO C++ > language - which includes template template parameters and partial template > specialisation. Does GCC support them yet? I need a compiler for Windows > as well. Borland C++ 5.5 seems to do the job but I've had no luck making it > work with the Turbo Debugger. Perhaps someone can provide me with help > there? > > BTW, does anyone know whats happened to the SWENG mailing list. I've sent > some messages out but I haven't received any. Is it down? > > Best regards, > > Matt Davies > Programmer, Confounding Factor > ma...@co... > www.confounding-factor.com > > _______________________________________________ > Gamedevlists-linux mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-linux |
From: Gareth H. <gar...@ac...> - 2001-12-11 19:20:27
|
GCC 3.0.2 is perhaps the best (released) version of GCC I've used. The C++ compiler is meant to be ISO C++ compliant, but as I don't really do any C++ programming I can't verify this. I would recommend checking this out initially. For example, the x86 backend was rewritten for 3.0, and generally produces much better code -- my personal favourite is moving floating point data through the integer registers when appropriate (integer regs: 2 cycle latency, fp regs: 7 cycle latency on a P4, for instance). -- Gareth |
From: Colin F. <cp...@ea...> - 2001-12-12 07:27:21
|
December 11, 4004 B.C. Tuesday I have a Linux shared-library (*.so) file with lots of C++ classes. I would like to determine the addresses of the binary code implementations of various NON-STATIC member functions at run-time (not at compile-time or doing "nm foo.so" at the command line). For example, let's say I have: class Foo { public: int Bar( int, char *, float ); }; I'd like to do something like: printf( "%p", &(Foo::Bar) ); The problem is, this print statement gives me a wacky answer (like 0xffff0000, for example). I know that pointer-to-member-function is more than a simple C pointer -- since it must have information regarding virtual function tables, etc. I also know that there is an implicit "this" parameter to all non-static member functions: int Foo::Bar( [Foo *this,] int, char *, float ); IMPLICIT Perhaps this is not always the case, especially if the member function only accesses static member functions and variables -- in which case the "this" parameter is superfluous. Anyhow, I want a 32-bit address of the assembly language implementation of Foo::Bar() without instantiating a Foo class object, and without calling Foo::Bar(). *** I don't mind any assembly language "hack", or any non-portable, frown-upon trickery. *** Ideally the technique would be "self-contained"; i.e., something I could do with a few lines of code or assembly code, without changing any external source files. For example, I *don't* want to modify the source code of the C++ classes themselves! Oh, and the technique must do calculations at run-time, and must work even for re-located shared-library code. One idea I had for this problem is this: write code to call the method, but never execute it, and then search backwards for the "call" instruction, and get the address. That leads me to another question: How can I get the run-time address of C++ statements? For example, suppose I do this: goto my_label; my_label: printf("Happy day, citizen!\n"); Could I figure out the approximate address of the "printf" call (NOT the location of the implementation of printf(), but the local "line" of code where the "call printf" assembly language is) just by doing the following: printf( "%x", (unsigned int)(my_label) ); or something similar? Am I allowed to read any code pages just like memory allocated on the heap? I mean *MY* code pages. So is it possible to scan through the assembly language opcodes of my own program to search for code? Okay, that's a lot of material -- and probably too hard-core for this list -- but I think a few of you guys have the expertise to help me with this puzzle. I did lots of Google searching, but everyone is happy making statements like "just declare a pointer-to-member-function to implement callbacks...C++ is great...who cares about the secret mechanics!" --- Colin P. Fahey |
From: Ryan C. G. <ic...@cl...> - 2001-12-12 07:47:09
|
> That leads me to another question: How can > I get the run-time address of C++ statements? > For example, suppose I do this: > > goto my_label; > > my_label: > printf("Happy day, citizen!\n"); > > Could I figure out the approximate address of > the "printf" call (NOT the location of the > implementation of printf(), but the local > "line" of code where the "call printf" > assembly language is) just by doing the > following: > > printf( "%x", (unsigned int)(my_label) ); > > or something similar? Not portably. There IS a gcc extension, though: printf("address of my_label is (%p).\n", &&my_label); That is TWO ampersands, and is NOT a typo. And did I mention it's not portable. Chances are, if you need this, you also need to rethink your design. > Am I allowed to read any code pages just like > memory allocated on the heap? I mean *MY* code > pages. So is it possible to scan through the > assembly language opcodes of my own program > to search for code? By default, you have read and execute access to memory pages that represent your program. You need to change that to have write access, too, if you plan to do any self-modifying code, or you'll segfault. --ryan. |
From: D. S. <st...@id...> - 2001-12-12 08:46:33
|
"Ryan C. Gordon" wrote: > > > That leads me to another question: How can > > I get the run-time address of C++ statements? > > For example, suppose I do this: > > > > goto my_label; > > > > my_label: > > printf("Happy day, citizen!\n"); > > > > Could I figure out the approximate address of > > the "printf" call (NOT the location of the > > implementation of printf(), but the local > > "line" of code where the "call printf" > > assembly language is) just by doing the > > following: > > > > printf( "%x", (unsigned int)(my_label) ); > > > > or something similar? > > Not portably. There IS a gcc extension, though: > > printf("address of my_label is (%p).\n", &&my_label); If you don't mind compiling it in, there are standard defines under gcc (I think on most platforms, not just linux) of __FILE__ and __LINE__. E.G.: printf( "%s at line %s\n", __FILE__, __LINE__ ); Assuming you can live with file name and line number, it'll do the trick. D. Stimits, st...@id... > > That is TWO ampersands, and is NOT a typo. > > And did I mention it's not portable. Chances are, if you need this, you > also need to rethink your design. > > > Am I allowed to read any code pages just like > > memory allocated on the heap? I mean *MY* code > > pages. So is it possible to scan through the > > assembly language opcodes of my own program > > to search for code? > > By default, you have read and execute access to memory pages that > represent your program. You need to change that to have write access, too, > if you plan to do any self-modifying code, or you'll segfault. > > --ryan. > > _______________________________________________ > Gamedevlists-linux mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-linux |
From: Steve B. <sjb...@ai...> - 2001-12-12 23:29:51
|
Colin Fahey wrote: > I have a Linux shared-library (*.so) file with lots > of C++ classes. I would like to determine the addresses > of the binary code implementations of various > NON-STATIC member functions at run-time (not at > compile-time or doing "nm foo.so" at the command line). Is dlopen/dlsym applicable here? What I don't understand is *WHY* you need to do this. It seems like you must be doing something unbelievably **NASTY** and you ought to be looking for a better way to solve the problem than delving around in ikky machine details such as code addresses. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
From: Ryan C. G. <ic...@cl...> - 2001-12-13 00:04:34
|
> Is dlopen/dlsym applicable here? The problem with dlsym() is that the symbol would be mangled in a way that varies between versions of gcc, so it's best for the dynamic linker to do this work. The odd thing is that, when statically linked, the code that Colin posted ( printf("%p", &(Foo::Bar)); ) works fine here. You could always do something like this (which is uglier, but probably safer, dlsym or otherwise): extern "C" { void FooBarEntry(void) { Foo::Bar(); } } then do your lookup on FoorBarEntry instead of Foo::Bar. I dunno. I tend to agree with Steve, there's probably a better way to do this without resorting to this sort of thing. > What I don't understand is *WHY* you need to do this. It seems > like you must be doing something unbelievably **NASTY** and you ought > to be looking for a better way to solve the problem than delving around > in ikky machine details such as code addresses. I'm rapidly coming to the belief that this should be the standard reply to any questions on this list. :) --ryan. |
From: Colin F. <cp...@ea...> - 2001-12-13 08:04:27
|
December 12th, 2001 Wednesday The primary reason I asked about finding the address of the implementation of non-static C++ class member functions was to satisfy my curiousity; I like to know how things work. But there was another reason... I built my own shared-library file (*.so), which had a few C and C++ static libraries (*.a) collected in there, in addition to my C++ object code (*.o). If you do "nm foo.so" and "objdump foo.so" you can learn a lot about the structure of the shared library file. In particular, you can see all of the function addresses (including non-static member functions). Okay, I also have an executable that loads my shared library at run-time. I have no source code for the executable, and it was stripped of symbols. When the executable invokes a method in my shared library, some part of the shared library causes a crash. There is code that successfully "unwinds" the call stack, so I get the addresses of all functions at the time of the crash. One of my co-workers wrote a Perl (ugh!) script that parses the stack trace and uses the output of "nm" and "objdump" to produce a friendly trace -- listing functions and line numbers! However, this script only works on regular executables with everything linked in. When a shared library is loaded, all of the code is re-located. In order to use the Perl script mentioned above, I had to determine where the code was placed in virtual memory. I picked an arbitrary function, printed its address at run-time, and compared this to the address indicated by "nm" or "objdump". I subtracted the difference in the Perl script, and now I get a valid stack trace for my shared library crash! ***NOTE: The function I chose was a straight C (extern "C" to avoid mangled names) function, whose address is trivial to print. *** Just to reassure myself that the addresses for the ***C++ non-static member functions*** were sane (in addition to the static member functions and straight C functions, whose addresses are trivial to print), I wanted to be able to print them -- thus the question I posted to this list. What I ended up doing was this: extern void MyFunction__8MyClassi(); printf( "%p", MyFunction__8MyClassi ); This prints the run-time address of the implementation of the non-static member function MyClass::MyFunction -- and my "extern" function prototype is completely artificial; it's just enough to keep the compiler from complaining about the symbol 'MyFunction__8MyClassi' being unknown... (...yet, heh, heh!) My fake prototype has to be a function (or something similar), but I don't need to match the arguments and return value of the actual function (with the specified mangled name). As I clearly mentioned in my initial post, I was willing to do any hack or frown-upon technique just to get the answer. This trick worked perfectly; I found that all of the code (C++ static and non-static functions alike) was relocated by the same constant offset at run-time. I'm still stuck with this crash, though. The problem is, part of the stack trace includes addresses that I can't explain. I can account for all of the code that is *DIRECTLY* contained in the shared library. But if the shared library itself loads even more shared libraries at run-time, and the crash is happening inside one of them...Uh, ohhh! Well, I won't bore you with more details of my problem (which is even more convoluted than I can explain here), but maybe I'll ask one last question: Can you use gdb to debug an executable- without-debugging-information just for the sake of debugging a shared library (whose symbols you *DO* have)? It's a crazy, multi-threaded, Java/C++ hybrid, with lots of library loading on both sides... Believe me, I completely agree that wanting to know the addresses of C++ member functions should never be necessary for any application! But I wanted to do some sanity checking before entertaining some wacky theories about the crashing. I'm not a Linux guru, and I haven't mastered debugging on that platform. Thanks, Ryan, for the interesting gcc compiler trick: printf("address of my_label is (%p).\n", &&my_label); I just like knowing that this can be done, even if I have no immediate plans to do this. --- Colin P. Fahey cp...@ea... |
From: Mark C. <me...@th...> - 2001-12-11 14:45:36
|
On Tuesday 11 December 2001 9:35 am, Matt Davies wrote: <snip> On a vaguely unrelated matter, the Linux beta of VectorC is going to be starting in a couple of months, and I've been given the task of finding people who want to beta test it. Let me know (off-list) if you're interested. -- === Mark 'Nurgle' Collins Lead Author - Linux Game Programming (Premiere Press) Author - Advanced AI Game Development (WordWare) Email: me...@th... Phone: +44 7761 774 152 Email: nu...@is... Spam: sp...@th... |