Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.os2.programmer.misc > #1252 > unrolled thread

VAC4 & malloc error message

Started by"A.D. Fundum" <what.ever@neverm.ind>
First post2013-09-19 17:56 +0200
Last post2013-09-21 17:01 +0200
Articles 4 — 2 participants

Back to article view | Back to comp.os.os2.programmer.misc


Contents

  VAC4 & malloc error message "A.D. Fundum" <what.ever@neverm.ind> - 2013-09-19 17:56 +0200
    Re: VAC4 & malloc error message Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-09-19 18:17 +0200
      Re: VAC4 & malloc error message "A.D. Fundum" <what.ever@neverm.ind> - 2013-09-20 01:22 +0200
        Re: VAC4 & malloc error message "A.D. Fundum" <what.ever@neverm.ind> - 2013-09-21 17:01 +0200

#1252 — VAC4 & malloc error message

From"A.D. Fundum" <what.ever@neverm.ind>
Date2013-09-19 17:56 +0200
SubjectVAC4 & malloc error message
Message-ID<o8uYFJ3iqTdG-pn2-JPHCFJeE9dK6@localhost>
Seems to work with VAC3, fails with VAC4. Why? 

Probably a basic error, an outdated copied coding style and/or a VAC4 
error. No fixpaks installed, I just gave it a try.



#define MAXDAYS 264
typedef struct _TRADE1 {ULONG date;} TRADE1; 
TRADE1 *trade1;

if (NULL==(trade1=malloc(MAXDAYS*sizeof(TRADE1))))

[Msg] CPP0216E: An expression of type "void*" cannot be converted to 
"_HAND1 *".


--

[toc] | [next] | [standalone]


#1253

FromMarcel Müller <news.5.maazl@spamgourmet.org>
Date2013-09-19 18:17 +0200
Message-ID<523b23b6$0$9518$9b4e6d93@newsspool1.arcor-online.net>
In reply to#1252
On 19.09.13 17.56, A.D. Fundum wrote:
> if (NULL==(trade1=malloc(MAXDAYS*sizeof(TRADE1))))

This assignment is invalid in C++.
In C silent conversions from or to void* are usually accepted.

Did you accidentally switch to C++ mode?

> [Msg] CPP0216E: An expression of type "void*" cannot be converted to
> "_HAND1 *".

To be safe write

if (NULL==(trade1=(TRADE1*)malloc(MAXDAYS*sizeof(TRADE1))))


Marcel

[toc] | [prev] | [next] | [standalone]


#1256

From"A.D. Fundum" <what.ever@neverm.ind>
Date2013-09-20 01:22 +0200
Message-ID<o8uYFJ3iqTdG-pn2-tDQGE67ijFBd@localhost>
In reply to#1253
> Did you accidentally switch to C++ mode?

I'll try to verify that later, I restored the system after having seen
v4 for OS/2 for the first time (not enough disk space on all systems 
to allow for several installed compilers anyway). I did use the IDE, 
so it could be some default setting indeed.

> "_HAND1 *".

Translation error ("_TRADE1 *") by me in the error description, but it
didn't matter.

> To be safe write
 
> if (NULL==(trade1=(TRADE1*)malloc(MAXDAYS*sizeof(TRADE1))))

knowledge++; thanks!


--

[toc] | [prev] | [next] | [standalone]


#1265

From"A.D. Fundum" <what.ever@neverm.ind>
Date2013-09-21 17:01 +0200
Message-ID<o8uYFJ3iqTdG-pn2-F6dFZmtdm9dn@localhost>
In reply to#1256
>> Did you accidentally switch to C++ mode?
 
> I'll try to verify that later

Indeed it's C++ when the VAC4 IDE was used for a quick try, i.e. a 
change from VAC3's default /Td setting. I didn't find an IDE C++ 
setting, but a "cout << endl;" worked after including <iostream.h> in 
my *.C file.


--

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.os2.programmer.misc


csiph-web