public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: how to declare dynamic 2-dimensional array in C++?
       [not found]   ` <386fac89@eeyore.callnetuk.com>
@ 2000-01-02 21:35     ` Alex Vinokur
  2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-04-01  0:00       ` Alex Vinokur
  0 siblings, 2 replies; 12+ messages in thread
From: Alex Vinokur @ 2000-01-02 21:35 UTC (permalink / raw)
  To: help-gcc

In article <386fac89@eeyore.callnetuk.com>,
  "Chris Newton" <not@all.likely> wrote:
> Alex Vinokur <alexander.vinokur@telrad.co.il> wrote...
> > The following construction is valid
    in gcc/g++ compiler (See my original message).
>
> [snip]
>
> >
> >
> > int main ()
> > {
> >         foo (10, 200, 3000);
> >         return 0;
> > }
>
> Sorry, but no, that's not valid. Please see the C++ Standard, sections
> 8.3.4 (on arrays) and 5.19 (on the definition of an integral constant
> expression).
>
> Cheers,
> Chris
>
>

GNU compiler (gcc/g++/egcs) contains several advanced non-standard
features. For instance,
	1. void foo (int s1, int s2, int s3)
	   {
		char    aaa [s1] [s2] [s3];
	   }
	   That code is legal in g++.

	2. switch (value)
	   {
		case 1 :
			break;

		case 100 ... 200 : // Legal in g++
			break;
	   }

	3. __PRETTY_FUNCTION__
  	   --FUNCTION__

	(Does anybody know something else?)

(I think) All these feature are very useful.
Of course we have to realize that they are non-standard.
By the way, is it worth standardizing them?

	Alex






Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-02 21:35     ` how to declare dynamic 2-dimensional array in C++? Alex Vinokur
@ 2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-01-03 10:16         ` Martin Ambuhl
                           ` (2 more replies)
  2000-04-01  0:00       ` Alex Vinokur
  1 sibling, 3 replies; 12+ messages in thread
From: Johnny Favorite (it means "Writhing Tentacle of Death") @ 2000-01-03  3:55 UTC (permalink / raw)
  To: help-gcc

Alex Vinokur wrote:
> 3. __PRETTY_FUNCTION__
>     --FUNCTION__


Since your other two examples were pretty cool-sounding I have to ask about
this one.  What the heck does __PRETTY_FUNCTION__ do?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
@ 2000-01-03 10:16         ` Martin Ambuhl
  2000-01-03 11:04           ` Greg Comeau
                             ` (2 more replies)
  2000-01-04  5:55         ` __PRETTY_FUNCTION__, functions and templates Alex Vinokur
  2000-04-01  0:00         ` how to declare dynamic 2-dimensional array in C++? Johnny Favorite (it means "Writhing Tentacle of Death")
  2 siblings, 3 replies; 12+ messages in thread
From: Martin Ambuhl @ 2000-01-03 10:16 UTC (permalink / raw)
  To: help-gcc

"Johnny Favorite (it means \"Writhing Tentacle of Death\")" wrote:
> 
> Alex Vinokur wrote:
> > 3. __PRETTY_FUNCTION__
> >     --FUNCTION__
> 
> Since your other two examples were pretty cool-sounding I have to ask about
> this one.  What the heck does __PRETTY_FUNCTION__ do?

File: gcc.info,  Node: Function Names,  Next: Return Address,  Prev:
Incomplete Enums,  Up: C Extensions

Function Names as Strings
=========================

   GNU CC predefines two string variables to be the name of the current
function.  The variable `__FUNCTION__' is the name of the function as
it appears in the source.  The variable `__PRETTY_FUNCTION__' is the
name of the function pretty printed in a language specific fashion.

   These names are always the same in a C function, but in a C++
function they may be different.  For example, this program:

     extern "C" {
     extern int printf (char *, ...);
     }
     
     class a {
      public:
       sub (int i)
         {
           printf ("__FUNCTION__ = %s\n", __FUNCTION__);
           printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
         }
     };
     
     int
     main (void)
     {
       a ax;
       ax.sub (0);
       return 0;
     }

gives this output:

     __FUNCTION__ = sub
     __PRETTY_FUNCTION__ = int  a::sub (int)

   These names are not macros: they are predefined string variables.
For example, `#ifdef __FUNCTION__' does not have any special meaning
inside a function, since the preprocessor does not do anything special
with the identifier `__FUNCTION__'.



-- 
Martin Ambuhl	mambuhl@earthlink.net

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03 10:16         ` Martin Ambuhl
@ 2000-01-03 11:04           ` Greg Comeau
  2000-04-01  0:00             ` Greg Comeau
  2000-01-04  4:24           ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-04-01  0:00           ` Martin Ambuhl
  2 siblings, 1 reply; 12+ messages in thread
From: Greg Comeau @ 2000-01-03 11:04 UTC (permalink / raw)
  To: help-gcc

In article < 3870E536.5A00FA79@earthlink.net > Martin Ambuhl <mambuhl@earthlink.net> writes:
>"Johnny Favorite (it means \"Writhing Tentacle of Death\")" wrote:
>> Alex Vinokur wrote:
>> > 3. __PRETTY_FUNCTION__
>> >     --FUNCTION__
>> 
>> Since your other two examples were pretty cool-sounding I have to ask about
>> this one.  What the heck does __PRETTY_FUNCTION__ do?
>
>File: gcc.info,  Node: Function Names,  Next: Return Address,  Prev:
>Incomplete Enums,  Up: C Extensions
>
>Function Names as Strings
>=========================
>
>   GNU CC predefines two string variables to be the name of the current
>function.  The variable `__FUNCTION__' is the name of the function as
>it appears in the source.  The variable `__PRETTY_FUNCTION__' is the
>name of the function pretty printed in a language specific fashion.

BTW, C99 now support an __func__ predefined variable to do this.

- Greg
-- 
       Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
          Producers of Comeau C/C++ 4.2.42 -- NOTE 4.2.42 NOW AVAILABLE
    Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
                *** WEB: http://www.comeaucomputing.com *** 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03 10:16         ` Martin Ambuhl
  2000-01-03 11:04           ` Greg Comeau
@ 2000-01-04  4:24           ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-04-01  0:00             ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-04-01  0:00           ` Martin Ambuhl
  2 siblings, 1 reply; 12+ messages in thread
From: Johnny Favorite (it means "Writhing Tentacle of Death") @ 2000-01-04  4:24 UTC (permalink / raw)
  To: help-gcc

Martin Ambuhl wrote:
> File: gcc.info,  Node: Function Names,  Next: Return Address,
> Prev: Incomplete Enums,  Up: C Extensions

Thanks!  I'm using GCC for BeOS and we don't get those .info files.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* __PRETTY_FUNCTION__, functions and templates
  2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-01-03 10:16         ` Martin Ambuhl
@ 2000-01-04  5:55         ` Alex Vinokur
  2000-04-01  0:00           ` Alex Vinokur
  2000-04-01  0:00         ` how to declare dynamic 2-dimensional array in C++? Johnny Favorite (it means "Writhing Tentacle of Death")
  2 siblings, 1 reply; 12+ messages in thread
From: Alex Vinokur @ 2000-01-04  5:55 UTC (permalink / raw)
  To: help-gcc

In article < 84pus001rnr@enews2.newsguy.com >,
  "Johnny Favorite (it means \"Writhing Tentacle of Death\")"
<allen@snakebite.com> wrote:
> Alex Vinokur wrote:
> > 3. __PRETTY_FUNCTION__
> >     --FUNCTION__
>
> Since your other two examples were pretty cool-sounding I have to ask
about
> this one.  What the heck does __PRETTY_FUNCTION__ do?
>
>


Here is an example.

        Alex

//#########################################################
//------------------- C++ code : BEGIN -------------------

#include <iostream>
#include <string>


//==========================================
//------------------------------------------
void foo1 ()
{
        cout << __PRETTY_FUNCTION__ << endl;
}

//------------------------------------------
int foo2 (const string& s1_1, char c1_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
        return 0;
}


//------------------------------------------
template <typename S1, typename S2, typename S3>
void foo3 (const S1& a1_i, S2& a2_i, S3 a3_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
}


//------------------------------------------
template <typename S1, typename S2, typename S3>
void foo4 ()
{
        cout << __PRETTY_FUNCTION__ << endl;
}


//------------------------------------------
template <typename S0, typename S1, typename S2, typename S3>
S0 foo5 (const S1& a1_i, S2& a2_i, S3 a3_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
        return S0 ();
}


//==========================================
class AAA
{
        public :
                //--------------------------
                void fooAAA1_1 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                void fooAAA1_2 () const
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                static void fooAAA1_3 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                int fooAAA2 (const string& s1_1, char c1_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return 0;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooAAA3 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooAAA4 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S0, typename S1, typename S2,
typename S3>
                S0 fooAAA5 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return S0 ();
                }
};



//==========================================
template <typename T1, typename T2>
class BBB
{
        public :
                //--------------------------
                void fooBBB1_1 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                void fooBBB1_2 () const
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                static void fooBBB1_3 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                int fooBBB2 (const string& s1_1, char c1_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return 0;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooBBB3 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooBBB4 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S0, typename S1, typename S2,
typename S3>
                S0 fooBBB5 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return S0 ();
                }
};

//==========================================
class XXX {};
class YYY {};
class ZZZ {};

//==========================================

int main ()
{
char            char_value      = 'Z';
int             int_value       = 123;
string          string_value    = "ABCDE";
XXX             XXX_value;
YYY             YYY_value;

        //===============================
        cout << endl;
        foo1 ();

        foo2 (string_value, char_value);

        foo3 (string_value, char_value, XXX_value);
        foo3 (YYY_value, char_value, XXX_value);

        foo4<YYY, int, string> ();
        foo4<YYY, XXX, YYY> ();

        foo5<int> (string_value, char_value, XXX_value);
        foo5<YYY> (char_value, int_value, XXX_value);

        //===============================
        cout << endl;

AAA     aaa;
        aaa.fooAAA1_1 ();

        aaa.fooAAA1_2 ();

        aaa.fooAAA1_3 ();

        aaa.fooAAA2 (string_value, char_value);

        aaa.fooAAA3 (string_value, char_value, XXX_value);
        aaa.fooAAA3 (YYY_value, char_value, XXX_value);

        aaa.template fooAAA4<YYY, int, string> ();
        aaa.template fooAAA4<YYY, XXX, YYY> ();

        aaa.template fooAAA5<int> (string_value, char_value, XXX_value);
        aaa.template fooAAA5<YYY> (char_value, int_value, XXX_value);


        //===============================
        cout << endl;

BBB<int, char>  bbb1;

        bbb1.fooBBB1_1 ();

        bbb1.fooBBB1_2 ();

        bbb1.fooBBB1_3 ();

        bbb1.fooBBB2 (string_value, char_value);

        bbb1.fooBBB3 (string_value, char_value, XXX_value);
        bbb1.fooBBB3 (YYY_value, char_value, XXX_value);

        bbb1.template fooBBB4<YYY, int, string> ();
        bbb1.template fooBBB4<YYY, XXX, YYY> ();

        bbb1.template fooBBB5<int> (string_value, char_value,
XXX_value);
        bbb1.template fooBBB5<YYY> (char_value, int_value, XXX_value);


        //===============================
        cout << endl;

BBB<XXX, int>   bbb2;

        bbb2.fooBBB1_1 ();

        bbb2.fooBBB1_2 ();

        bbb2.fooBBB1_3 ();

        bbb2.fooBBB2 (string_value, char_value);

        bbb2.fooBBB3 (string_value, char_value, XXX_value);
        bbb2.fooBBB3 (YYY_value, char_value, XXX_value);

        bbb2.template fooBBB4<YYY, int, string> ();
        bbb2.template fooBBB4<YYY, XXX, YYY> ();

        bbb2.template fooBBB5<int> (string_value, char_value,
XXX_value);
        bbb2.template fooBBB5<YYY> (char_value, int_value, XXX_value);

        //===============================
        cout << endl;
        bbb2.template fooBBB5<ZZZ> (bbb1, aaa, bbb2);
        return 0;
}


//------------------- C++ code : END ----------------------





//#########################################################
//------------------- Running Results : BEGIN -------------

void foo1()
int foo2(const class string &, char)
void foo3<string, char, XXX>(const class string &, char &, class XXX)
void foo3<YYY, char, XXX>(const class YYY &, char &, class XXX)
void foo4<YYY, int, string>()
void foo4<YYY, XXX, YYY>()
int foo5<int, string, char, XXX>(const class string &, char &, class
XXX)
class YYY foo5<YYY, char, int, XXX>(const char &, int &, class XXX)

void AAA::fooAAA1_1()
void AAA::fooAAA1_2() const
static void AAA::fooAAA1_3()
int AAA::fooAAA2(const class string &, char)
void AAA::fooAAA3<string, char, XXX>(const class string &, char &, class
XXX)
void AAA::fooAAA3<YYY, char, XXX>(const class YYY &, char &, class XXX)
void AAA::fooAAA4<YYY, int, string>()
void AAA::fooAAA4<YYY, XXX, YYY>()
int AAA::fooAAA5<int, string, char, XXX>(const class string &, char &,
class XXX)
class YYY AAA::fooAAA5<YYY, char, int, XXX>(const char &, int &, class
XXX)

void BBB<int,char>::fooBBB1_1<int, char>()    ### Attention ###
void BBB<int,char>::fooBBB1_2<int, char>() const    ### Attention ###
static void BBB<int,char>::fooBBB1_3<int, char>()    ### Attention ###
int BBB<int,char>::fooBBB2<int, char>(const class string &, char)    ###
Attention ###
void BBB<int,char>::fooBBB3<string, char, XXX>(const class string &,
char &, class XXX)
void BBB<int,char>::fooBBB3<YYY, char, XXX>(const class YYY &, char &,
class XXX)
void BBB<int,char>::fooBBB4<YYY, int, string>()
void BBB<int,char>::fooBBB4<YYY, XXX, YYY>()
int BBB<int,char>::fooBBB5<int, string, char, XXX>(const class string &,
char &, class XXX)
class YYY BBB<int,char>::fooBBB5<YYY, char, int, XXX>(const char &, int
&, class XXX)

void BBB<XXX,int>::fooBBB1_1<XXX, int>()    ### Attention ###
void BBB<XXX,int>::fooBBB1_2<XXX, int>() const    ### Attention ###
static void BBB<XXX,int>::fooBBB1_3<XXX, int>()    ### Attention ###
int BBB<XXX,int>::fooBBB2<XXX, int>(const class string &, char)    ###
Attention ###
void BBB<XXX,int>::fooBBB3<string, char, XXX>(const class string &, char
&, class XXX)
void BBB<XXX,int>::fooBBB3<YYY, char, XXX>(const class YYY &, char &,
class XXX)
void BBB<XXX,int>::fooBBB4<YYY, int, string>()
void BBB<XXX,int>::fooBBB4<YYY, XXX, YYY>()
int BBB<XXX,int>::fooBBB5<int, string, char, XXX>(const class string &,
char &, class XXX)
class YYY BBB<XXX,int>::fooBBB5<YYY, char, int, XXX>(const char &, int
&, class XXX)

class ZZZ BBB<XXX,int>::fooBBB5<ZZZ, BBB<int,char>, AAA,
BBB<XXX,int>>(const class BBB<int,char> &, class AAA &, class
BBB<XXX,int>)

//------------------- Running Results : END ---------------



//#########################################################
//------------------- Environment -------------------------

g++ -v     : gcc version egcs-2.91.57 19980901
             (egcs-1.1 release)

uname -sr  : SunOS 5.6

//---------------------------------------------------------



//#########################################################



Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-04  4:24           ` Johnny Favorite (it means "Writhing Tentacle of Death")
@ 2000-04-01  0:00             ` Johnny Favorite (it means "Writhing Tentacle of Death")
  0 siblings, 0 replies; 12+ messages in thread
From: Johnny Favorite (it means "Writhing Tentacle of Death") @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

Martin Ambuhl wrote:
> File: gcc.info,  Node: Function Names,  Next: Return Address,
> Prev: Incomplete Enums,  Up: C Extensions

Thanks!  I'm using GCC for BeOS and we don't get those .info files.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-02 21:35     ` how to declare dynamic 2-dimensional array in C++? Alex Vinokur
  2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
@ 2000-04-01  0:00       ` Alex Vinokur
  1 sibling, 0 replies; 12+ messages in thread
From: Alex Vinokur @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

In article <386fac89@eeyore.callnetuk.com>,
  "Chris Newton" <not@all.likely> wrote:
> Alex Vinokur <alexander.vinokur@telrad.co.il> wrote...
> > The following construction is valid
    in gcc/g++ compiler (See my original message).
>
> [snip]
>
> >
> >
> > int main ()
> > {
> >         foo (10, 200, 3000);
> >         return 0;
> > }
>
> Sorry, but no, that's not valid. Please see the C++ Standard, sections
> 8.3.4 (on arrays) and 5.19 (on the definition of an integral constant
> expression).
>
> Cheers,
> Chris
>
>

GNU compiler (gcc/g++/egcs) contains several advanced non-standard
features. For instance,
	1. void foo (int s1, int s2, int s3)
	   {
		char    aaa [s1] [s2] [s3];
	   }
	   That code is legal in g++.

	2. switch (value)
	   {
		case 1 :
			break;

		case 100 ... 200 : // Legal in g++
			break;
	   }

	3. __PRETTY_FUNCTION__
  	   --FUNCTION__

	(Does anybody know something else?)

(I think) All these feature are very useful.
Of course we have to realize that they are non-standard.
By the way, is it worth standardizing them?

	Alex






Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2000-01-03 10:16         ` Martin Ambuhl
  2000-01-04  5:55         ` __PRETTY_FUNCTION__, functions and templates Alex Vinokur
@ 2000-04-01  0:00         ` Johnny Favorite (it means "Writhing Tentacle of Death")
  2 siblings, 0 replies; 12+ messages in thread
From: Johnny Favorite (it means "Writhing Tentacle of Death") @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

Alex Vinokur wrote:
> 3. __PRETTY_FUNCTION__
>     --FUNCTION__


Since your other two examples were pretty cool-sounding I have to ask about
this one.  What the heck does __PRETTY_FUNCTION__ do?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03 10:16         ` Martin Ambuhl
  2000-01-03 11:04           ` Greg Comeau
  2000-01-04  4:24           ` Johnny Favorite (it means "Writhing Tentacle of Death")
@ 2000-04-01  0:00           ` Martin Ambuhl
  2 siblings, 0 replies; 12+ messages in thread
From: Martin Ambuhl @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

"Johnny Favorite (it means \"Writhing Tentacle of Death\")" wrote:
> 
> Alex Vinokur wrote:
> > 3. __PRETTY_FUNCTION__
> >     --FUNCTION__
> 
> Since your other two examples were pretty cool-sounding I have to ask about
> this one.  What the heck does __PRETTY_FUNCTION__ do?

File: gcc.info,  Node: Function Names,  Next: Return Address,  Prev:
Incomplete Enums,  Up: C Extensions

Function Names as Strings
=========================

   GNU CC predefines two string variables to be the name of the current
function.  The variable `__FUNCTION__' is the name of the function as
it appears in the source.  The variable `__PRETTY_FUNCTION__' is the
name of the function pretty printed in a language specific fashion.

   These names are always the same in a C function, but in a C++
function they may be different.  For example, this program:

     extern "C" {
     extern int printf (char *, ...);
     }
     
     class a {
      public:
       sub (int i)
         {
           printf ("__FUNCTION__ = %s\n", __FUNCTION__);
           printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
         }
     };
     
     int
     main (void)
     {
       a ax;
       ax.sub (0);
       return 0;
     }

gives this output:

     __FUNCTION__ = sub
     __PRETTY_FUNCTION__ = int  a::sub (int)

   These names are not macros: they are predefined string variables.
For example, `#ifdef __FUNCTION__' does not have any special meaning
inside a function, since the preprocessor does not do anything special
with the identifier `__FUNCTION__'.



-- 
Martin Ambuhl	mambuhl@earthlink.net

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: how to declare dynamic 2-dimensional array in C++?
  2000-01-03 11:04           ` Greg Comeau
@ 2000-04-01  0:00             ` Greg Comeau
  0 siblings, 0 replies; 12+ messages in thread
From: Greg Comeau @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

In article < 3870E536.5A00FA79@earthlink.net > Martin Ambuhl <mambuhl@earthlink.net> writes:
>"Johnny Favorite (it means \"Writhing Tentacle of Death\")" wrote:
>> Alex Vinokur wrote:
>> > 3. __PRETTY_FUNCTION__
>> >     --FUNCTION__
>> 
>> Since your other two examples were pretty cool-sounding I have to ask about
>> this one.  What the heck does __PRETTY_FUNCTION__ do?
>
>File: gcc.info,  Node: Function Names,  Next: Return Address,  Prev:
>Incomplete Enums,  Up: C Extensions
>
>Function Names as Strings
>=========================
>
>   GNU CC predefines two string variables to be the name of the current
>function.  The variable `__FUNCTION__' is the name of the function as
>it appears in the source.  The variable `__PRETTY_FUNCTION__' is the
>name of the function pretty printed in a language specific fashion.

BTW, C99 now support an __func__ predefined variable to do this.

- Greg
-- 
       Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
          Producers of Comeau C/C++ 4.2.42 -- NOTE 4.2.42 NOW AVAILABLE
    Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
                *** WEB: http://www.comeaucomputing.com *** 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* __PRETTY_FUNCTION__, functions and templates
  2000-01-04  5:55         ` __PRETTY_FUNCTION__, functions and templates Alex Vinokur
@ 2000-04-01  0:00           ` Alex Vinokur
  0 siblings, 0 replies; 12+ messages in thread
From: Alex Vinokur @ 2000-04-01  0:00 UTC (permalink / raw)
  To: help-gcc

In article < 84pus001rnr@enews2.newsguy.com >,
  "Johnny Favorite (it means \"Writhing Tentacle of Death\")"
<allen@snakebite.com> wrote:
> Alex Vinokur wrote:
> > 3. __PRETTY_FUNCTION__
> >     --FUNCTION__
>
> Since your other two examples were pretty cool-sounding I have to ask
about
> this one.  What the heck does __PRETTY_FUNCTION__ do?
>
>


Here is an example.

        Alex

//#########################################################
//------------------- C++ code : BEGIN -------------------

#include <iostream>
#include <string>


//==========================================
//------------------------------------------
void foo1 ()
{
        cout << __PRETTY_FUNCTION__ << endl;
}

//------------------------------------------
int foo2 (const string& s1_1, char c1_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
        return 0;
}


//------------------------------------------
template <typename S1, typename S2, typename S3>
void foo3 (const S1& a1_i, S2& a2_i, S3 a3_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
}


//------------------------------------------
template <typename S1, typename S2, typename S3>
void foo4 ()
{
        cout << __PRETTY_FUNCTION__ << endl;
}


//------------------------------------------
template <typename S0, typename S1, typename S2, typename S3>
S0 foo5 (const S1& a1_i, S2& a2_i, S3 a3_i)
{
        cout << __PRETTY_FUNCTION__ << endl;
        return S0 ();
}


//==========================================
class AAA
{
        public :
                //--------------------------
                void fooAAA1_1 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                void fooAAA1_2 () const
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                static void fooAAA1_3 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                int fooAAA2 (const string& s1_1, char c1_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return 0;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooAAA3 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooAAA4 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S0, typename S1, typename S2,
typename S3>
                S0 fooAAA5 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return S0 ();
                }
};



//==========================================
template <typename T1, typename T2>
class BBB
{
        public :
                //--------------------------
                void fooBBB1_1 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                void fooBBB1_2 () const
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                static void fooBBB1_3 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                int fooBBB2 (const string& s1_1, char c1_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return 0;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooBBB3 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S1, typename S2, typename S3>
                void fooBBB4 ()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }
                //--------------------------
                template <typename S0, typename S1, typename S2,
typename S3>
                S0 fooBBB5 (const S1& a1_i, S2& a2_i, S3 a3_i)
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                        return S0 ();
                }
};

//==========================================
class XXX {};
class YYY {};
class ZZZ {};

//==========================================

int main ()
{
char            char_value      = 'Z';
int             int_value       = 123;
string          string_value    = "ABCDE";
XXX             XXX_value;
YYY             YYY_value;

        //===============================
        cout << endl;
        foo1 ();

        foo2 (string_value, char_value);

        foo3 (string_value, char_value, XXX_value);
        foo3 (YYY_value, char_value, XXX_value);

        foo4<YYY, int, string> ();
        foo4<YYY, XXX, YYY> ();

        foo5<int> (string_value, char_value, XXX_value);
        foo5<YYY> (char_value, int_value, XXX_value);

        //===============================
        cout << endl;

AAA     aaa;
        aaa.fooAAA1_1 ();

        aaa.fooAAA1_2 ();

        aaa.fooAAA1_3 ();

        aaa.fooAAA2 (string_value, char_value);

        aaa.fooAAA3 (string_value, char_value, XXX_value);
        aaa.fooAAA3 (YYY_value, char_value, XXX_value);

        aaa.template fooAAA4<YYY, int, string> ();
        aaa.template fooAAA4<YYY, XXX, YYY> ();

        aaa.template fooAAA5<int> (string_value, char_value, XXX_value);
        aaa.template fooAAA5<YYY> (char_value, int_value, XXX_value);


        //===============================
        cout << endl;

BBB<int, char>  bbb1;

        bbb1.fooBBB1_1 ();

        bbb1.fooBBB1_2 ();

        bbb1.fooBBB1_3 ();

        bbb1.fooBBB2 (string_value, char_value);

        bbb1.fooBBB3 (string_value, char_value, XXX_value);
        bbb1.fooBBB3 (YYY_value, char_value, XXX_value);

        bbb1.template fooBBB4<YYY, int, string> ();
        bbb1.template fooBBB4<YYY, XXX, YYY> ();

        bbb1.template fooBBB5<int> (string_value, char_value,
XXX_value);
        bbb1.template fooBBB5<YYY> (char_value, int_value, XXX_value);


        //===============================
        cout << endl;

BBB<XXX, int>   bbb2;

        bbb2.fooBBB1_1 ();

        bbb2.fooBBB1_2 ();

        bbb2.fooBBB1_3 ();

        bbb2.fooBBB2 (string_value, char_value);

        bbb2.fooBBB3 (string_value, char_value, XXX_value);
        bbb2.fooBBB3 (YYY_value, char_value, XXX_value);

        bbb2.template fooBBB4<YYY, int, string> ();
        bbb2.template fooBBB4<YYY, XXX, YYY> ();

        bbb2.template fooBBB5<int> (string_value, char_value,
XXX_value);
        bbb2.template fooBBB5<YYY> (char_value, int_value, XXX_value);

        //===============================
        cout << endl;
        bbb2.template fooBBB5<ZZZ> (bbb1, aaa, bbb2);
        return 0;
}


//------------------- C++ code : END ----------------------





//#########################################################
//------------------- Running Results : BEGIN -------------

void foo1()
int foo2(const class string &, char)
void foo3<string, char, XXX>(const class string &, char &, class XXX)
void foo3<YYY, char, XXX>(const class YYY &, char &, class XXX)
void foo4<YYY, int, string>()
void foo4<YYY, XXX, YYY>()
int foo5<int, string, char, XXX>(const class string &, char &, class
XXX)
class YYY foo5<YYY, char, int, XXX>(const char &, int &, class XXX)

void AAA::fooAAA1_1()
void AAA::fooAAA1_2() const
static void AAA::fooAAA1_3()
int AAA::fooAAA2(const class string &, char)
void AAA::fooAAA3<string, char, XXX>(const class string &, char &, class
XXX)
void AAA::fooAAA3<YYY, char, XXX>(const class YYY &, char &, class XXX)
void AAA::fooAAA4<YYY, int, string>()
void AAA::fooAAA4<YYY, XXX, YYY>()
int AAA::fooAAA5<int, string, char, XXX>(const class string &, char &,
class XXX)
class YYY AAA::fooAAA5<YYY, char, int, XXX>(const char &, int &, class
XXX)

void BBB<int,char>::fooBBB1_1<int, char>()    ### Attention ###
void BBB<int,char>::fooBBB1_2<int, char>() const    ### Attention ###
static void BBB<int,char>::fooBBB1_3<int, char>()    ### Attention ###
int BBB<int,char>::fooBBB2<int, char>(const class string &, char)    ###
Attention ###
void BBB<int,char>::fooBBB3<string, char, XXX>(const class string &,
char &, class XXX)
void BBB<int,char>::fooBBB3<YYY, char, XXX>(const class YYY &, char &,
class XXX)
void BBB<int,char>::fooBBB4<YYY, int, string>()
void BBB<int,char>::fooBBB4<YYY, XXX, YYY>()
int BBB<int,char>::fooBBB5<int, string, char, XXX>(const class string &,
char &, class XXX)
class YYY BBB<int,char>::fooBBB5<YYY, char, int, XXX>(const char &, int
&, class XXX)

void BBB<XXX,int>::fooBBB1_1<XXX, int>()    ### Attention ###
void BBB<XXX,int>::fooBBB1_2<XXX, int>() const    ### Attention ###
static void BBB<XXX,int>::fooBBB1_3<XXX, int>()    ### Attention ###
int BBB<XXX,int>::fooBBB2<XXX, int>(const class string &, char)    ###
Attention ###
void BBB<XXX,int>::fooBBB3<string, char, XXX>(const class string &, char
&, class XXX)
void BBB<XXX,int>::fooBBB3<YYY, char, XXX>(const class YYY &, char &,
class XXX)
void BBB<XXX,int>::fooBBB4<YYY, int, string>()
void BBB<XXX,int>::fooBBB4<YYY, XXX, YYY>()
int BBB<XXX,int>::fooBBB5<int, string, char, XXX>(const class string &,
char &, class XXX)
class YYY BBB<XXX,int>::fooBBB5<YYY, char, int, XXX>(const char &, int
&, class XXX)

class ZZZ BBB<XXX,int>::fooBBB5<ZZZ, BBB<int,char>, AAA,
BBB<XXX,int>>(const class BBB<int,char> &, class AAA &, class
BBB<XXX,int>)

//------------------- Running Results : END ---------------



//#########################################################
//------------------- Environment -------------------------

g++ -v     : gcc version egcs-2.91.57 19980901
             (egcs-1.1 release)

uname -sr  : SunOS 5.6

//---------------------------------------------------------



//#########################################################



Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2000-04-01  0:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <386da233.0@news.tm.net.my>
     [not found] ` <84n59m$daj$1@nnrp1.deja.com>
     [not found]   ` <386fac89@eeyore.callnetuk.com>
2000-01-02 21:35     ` how to declare dynamic 2-dimensional array in C++? Alex Vinokur
2000-01-03  3:55       ` Johnny Favorite (it means "Writhing Tentacle of Death")
2000-01-03 10:16         ` Martin Ambuhl
2000-01-03 11:04           ` Greg Comeau
2000-04-01  0:00             ` Greg Comeau
2000-01-04  4:24           ` Johnny Favorite (it means "Writhing Tentacle of Death")
2000-04-01  0:00             ` Johnny Favorite (it means "Writhing Tentacle of Death")
2000-04-01  0:00           ` Martin Ambuhl
2000-01-04  5:55         ` __PRETTY_FUNCTION__, functions and templates Alex Vinokur
2000-04-01  0:00           ` Alex Vinokur
2000-04-01  0:00         ` how to declare dynamic 2-dimensional array in C++? Johnny Favorite (it means "Writhing Tentacle of Death")
2000-04-01  0:00       ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).