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++ - SC/DMC Porting problem

↑ ↓ ← Richard M Thomas <rthomas mat.ethz.ch> writes:
Thinking of finally switching from SC7.5 to DMC++... In the meantime can 
anyone tell me why

pointer = new char[size];

compiles without problem in SC but produces

error '?_P(unsigned, char *, int)'

when compiled in exactly the same context with DMC++.
Secondly the IDDE compiler setting 'enable new[] delete[] overloading' 
seems to toggle itself to 'off' during compilation even when it has been 
set to 'on'.
Thanks for any suggestions
Richard
Jul 27 2003
"Walter" <walter digitalmars.com> writes:
"Richard M Thomas" <rthomas mat.ethz.ch> wrote in message
news:3F24025C.3060203 mat.ethz.ch...
 Thinking of finally switching from SC7.5 to DMC++... In the meantime can
 anyone tell me why

 pointer = new char[size];

 compiles without problem in SC but produces

 error '?_P(unsigned, char *, int)'

 when compiled in exactly the same context with DMC++.

Can you post a complete example? Thanks!
Jul 27 2003
↑ ↓ Richard M Thomas <rthomas mat.ethz.ch> writes:
Thanks for the response Walter.
I've seen the same error before and given up on it. The present 
occurence appears in a DIB handling class that I 'lifted' and was 
originally written in VC, I believe. Not sure how much code you need - 
there's more if you want it - just the offending function for now.
--
Cheers
Richard

(header ...
LPBITMAPINFOHEADER m_lpBMIH; )

CDib::CDib(CSize size, int nBitCount)
{
         m_hFile = NULL;
         m_hBitmap = NULL;
         m_hPalette = NULL;
         m_nBmihAlloc = m_nImageAlloc = noAlloc;
         Empty();
         ComputePaletteSize(nBitCount);
         m_lpBMIH = (LPBITMAPINFOHEADER) new
                 char[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 
m_nColorTableEntries];
//-->ERROR
         m_nBmihAlloc = crtAlloc;
         m_lpBMIH->biSize = sizeof(BITMAPINFOHEADER);
         m_lpBMIH->biWidth = size.cx;
         m_lpBMIH->biHeight = size.cy;
         m_lpBMIH->biPlanes = 1;
         m_lpBMIH->biBitCount = nBitCount;
         m_lpBMIH->biCompression = BI_RGB;
         m_lpBMIH->biSizeImage = 0;
         m_lpBMIH->biXPelsPerMeter = 0;
         m_lpBMIH->biYPelsPerMeter = 0;
         m_lpBMIH->biClrUsed = m_nColorTableEntries;
         m_lpBMIH->biClrImportant = m_nColorTableEntries;
         ComputeMetrics();
         memset(m_lpvColorTable, 0, sizeof(RGBQUAD) * m_nColorTableEntries);
         m_lpImage = NULL;  // no data yet
}
Jul 28 2003
↑ ↓ → "Walter" <walter digitalmars.com> writes:
I need enough to be able to compile it and reproduce the error message.
Thanks, -Walter

BTW, what memory model are you using?

"Richard M Thomas" <rthomas mat.ethz.ch> wrote in message
news:3F25935A.9060500 mat.ethz.ch...
 Thanks for the response Walter.
 I've seen the same error before and given up on it. The present
 occurence appears in a DIB handling class that I 'lifted' and was
 originally written in VC, I believe. Not sure how much code you need -
 there's more if you want it - just the offending function for now.
 --
 Cheers
 Richard

 (header ...
 LPBITMAPINFOHEADER m_lpBMIH; )

 CDib::CDib(CSize size, int nBitCount)
 {
          m_hFile = NULL;
          m_hBitmap = NULL;
          m_hPalette = NULL;
          m_nBmihAlloc = m_nImageAlloc = noAlloc;
          Empty();
          ComputePaletteSize(nBitCount);
          m_lpBMIH = (LPBITMAPINFOHEADER) new
                  char[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) *
 m_nColorTableEntries];
 //-->ERROR
          m_nBmihAlloc = crtAlloc;
          m_lpBMIH->biSize = sizeof(BITMAPINFOHEADER);
          m_lpBMIH->biWidth = size.cx;
          m_lpBMIH->biHeight = size.cy;
          m_lpBMIH->biPlanes = 1;
          m_lpBMIH->biBitCount = nBitCount;
          m_lpBMIH->biCompression = BI_RGB;
          m_lpBMIH->biSizeImage = 0;
          m_lpBMIH->biXPelsPerMeter = 0;
          m_lpBMIH->biYPelsPerMeter = 0;
          m_lpBMIH->biClrUsed = m_nColorTableEntries;
          m_lpBMIH->biClrImportant = m_nColorTableEntries;
          ComputeMetrics();
          memset(m_lpvColorTable, 0, sizeof(RGBQUAD) *

          m_lpImage = NULL;  // no data yet
 }

Jul 28 2003
Richard M Thomas <rthomas mat.ethz.ch> writes:
Thanks again Walter. The current version of the problem I'm having 
appears in an SDI project I'm working on and I'd like to stay in 
context. The code below produces the error when dropped as a class into 
a framework SDI project in DMC++ but compiles normally in SC7.5. I've 
come across the same error when trying to compile parts of 'Numerical 
Recipes in C++' - presumably when the compiler hits one of its 
allocation routines. Hope I'm not missing something....
All the best
Richard

+++
//(test.h)
class Test : public CObject
{
private:
     char* pointer;
public:
     Test(int size);
};

//(test.cpp)
#include "stdafx.h"
#include "test.h"

Test::Test(int size)
{
     pointer =  new char[size];
}
+++
Jul 30 2003
↑ ↓ → "Walter" <walter digitalmars.com> writes:
Thanks, I can take it from here. -Walter
Jul 30 2003