www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - std::cout << __FUNCTION__ << std::endl fails

↑ ↓ ← "Aneesh Dalvi" <aneesh tolv.ca> writes:
Does anyone know why the following code fails with the DMC compiler?

std::cout << __FUNCTION__ << std::endl;

This works with GCC and MSVC++.

__FUNCTION__ seems to be recognized by DMC, but still the code does not
compile.

Thanks
Jun 04 2004
↑ ↓ Jerry van Dijk <windows jvdsys.demon.nl> writes:
"Aneesh Dalvi" <aneesh tolv.ca> writes:

 Does anyone know why the following code fails with the DMC compiler?
 
 std::cout << __FUNCTION__ << std::endl;

It works here with 8.38n and using stlport 4.5.3: ------------------------------------------------------------------------------- D:\work>dir Volume in drive D is WorkDisk Volume Serial Number is 883F-94F1 Directory of D:\work 05-06-2004 00:20 <DIR> . 05-06-2004 00:20 <DIR> .. 05-06-2004 00:13 97 check.cpp 1 File(s) 97 bytes 2 Dir(s) 15.658.946.560 bytes free D:\work>cat check.cpp #include <iostream> using namespace std; int main() { cout << __FUNCTION__ << endl; } D:\work>dmc check.cpp link check,,,user32+kernel32/noi; D:\work>dir Volume in drive D is WorkDisk Volume Serial Number is 883F-94F1 Directory of D:\work 05-06-2004 00:20 <DIR> . 05-06-2004 00:20 <DIR> .. 05-06-2004 00:13 97 check.cpp 05-06-2004 00:20 361.500 check.exe 05-06-2004 00:20 2.204 check.map 05-06-2004 00:20 28.275 check.obj 4 File(s) 392.076 bytes 2 Dir(s) 15.658.549.248 bytes free D:\work>check main ------------------------------------------------------------------------------- Also checking if I have setup news properly :-) -- -- Jerry van Dijk -- Leiden, Holland
Jun 04 2004
↑ ↓ "Aneesh Dalvi" <aneesh tolv.ca> writes:
Yes, this works:

#include <iostream>

int main() {
    std::cout << __FUNCTION__ << std::endl;
    return 0;
}

However, this does not:

#include <iostream>

class test {
public:
  test() { std::cout << __FUNCTION__ << std::endl; }
};

int main() {
    test x;
    return 0;
}

C:\projects>c:\dm\bin\dmc -cpp -Ic:\dm\stlport\stlport test2.cc
test2.cc(5) : Error: expression expected
test2.cc(5) : Warning 6: value of expression is not used
--- errorlevel 1


- aneesh



"Jerry van Dijk" <windows jvdsys.demon.nl> wrote in message
news:ullj37yn1.fsf jvdsys.demon.nl...
 "Aneesh Dalvi" <aneesh tolv.ca> writes:

 Does anyone know why the following code fails with the DMC compiler?

 std::cout << __FUNCTION__ << std::endl;

It works here with 8.38n and using stlport 4.5.3: --------------------------------------------------------------------------

 D:\work>dir
  Volume in drive D is WorkDisk
  Volume Serial Number is 883F-94F1

  Directory of D:\work

 05-06-2004  00:20       <DIR>          .
 05-06-2004  00:20       <DIR>          ..
 05-06-2004  00:13                   97 check.cpp
                1 File(s)             97 bytes
                2 Dir(s)  15.658.946.560 bytes free

 D:\work>cat check.cpp
 #include <iostream>

 using namespace std;

 int main()
 {
         cout << __FUNCTION__ << endl;
 }

 D:\work>dmc check.cpp
 link check,,,user32+kernel32/noi;


 D:\work>dir
  Volume in drive D is WorkDisk
  Volume Serial Number is 883F-94F1

  Directory of D:\work

 05-06-2004  00:20       <DIR>          .
 05-06-2004  00:20       <DIR>          ..
 05-06-2004  00:13                   97 check.cpp
 05-06-2004  00:20              361.500 check.exe
 05-06-2004  00:20                2.204 check.map
 05-06-2004  00:20               28.275 check.obj
                4 File(s)        392.076 bytes
                2 Dir(s)  15.658.549.248 bytes free

 D:\work>check
 main
 --------------------------------------------------------------------------

 Also checking if I have setup news properly :-)

 -- 
 --  Jerry van Dijk
 --  Leiden, Holland

Jun 04 2004
↑ ↓ → Jerry van Dijk <windows jvdsys.demon.nl> writes:
"Aneesh Dalvi" <aneesh tolv.ca> writes:

 However, this does not:

 #include <iostream>
 
 class test {
 public:
   test() { std::cout << __FUNCTION__ << std::endl; }
 };
 
 int main() {
     test x;
     return 0;
 }

Even worse, this does: ------------------------------------------------------------- #include <iostream> class test { public: inline test(); inline ~test(); }; test::test() { std::cout << __FUNCTION__ << std::endl; } inline ~test(); test::~test() { std::cout << __FUNCTION__ << std::endl; } int main() { test x; } ------------------------------------------------------------ Since the dmc docs say: | __FUNCTION__ | | Same as __FUNC__. Provided for Gnu CC compatibility. it could be a bug if "Gnu CC" is also intended to mean gcc c++. Note also that the output of __FUNCTION__ differs from gcc: gcc prints: dmc prints: test test::test ~test test::~test -- -- Jerry van Dijk -- Leiden, Holland
Jun 05 2004