473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Can't decipher compiler error

The compiler(gcc) gives me this error

faxGettyApp.c++:596: ANSI C++ forbids implicit conversion from `void *' in
assignment
make[3]: *** [faxGettyApp.o] Error 1

on this code

void
faxGettyApp::setEnvVar(char* var, char* val)
{
char * v;
596 v = malloc( strlen(var) + strlen(val) + 2 );
if ( v == NULL )
traceServer("runGetty: setEnvVar: cannot malloc" );
else
{
sprintf( v, "%s=%s", var, val );
if ( putenv( v ) != 0 )
traceServer("runGetty: putenv: putenv failed" );
}
}
this function is called by:

setenv("ABCDEF", abcd)

where "abcd" is of type fxStr
where fxStr is special class for strings defined in the program.

What does this error mean?
Thanks

George
--
#
#...
Jul 22 '05 #1
2 1668

"George Bell" <ma*************@netscape.net> wrote in message
news:vG7pc.1256$65.768@lakeread06...
The compiler(gcc) gives me this error

faxGettyApp.c++:596: ANSI C++ forbids implicit conversion from `void *' in
assignment
make[3]: *** [faxGettyApp.o] Error 1

on this code

void
faxGettyApp::setEnvVar(char* var, char* val)
{
char * v;
596 v = malloc( strlen(var) + strlen(val) + 2 );
if ( v == NULL )
traceServer("runGetty: setEnvVar: cannot malloc" );
else
{
sprintf( v, "%s=%s", var, val );
if ( putenv( v ) != 0 )
traceServer("runGetty: putenv: putenv failed" );
}
}
this function is called by:

setenv("ABCDEF", abcd)

where "abcd" is of type fxStr
where fxStr is special class for strings defined in the program.

What does this error mean?
Thanks

George


Guess what, it means you cannot implicitly convert from void* (to char*).

char * v;
v = malloc( strlen(var) + strlen(val) + 2 );

v is type char*, malloc returns type void*. In C++ it is not legal to
convert from void* to char*. It is legal in C, maybe this is what is
confusing you, the code you've posted looks like C code not C++ code.
Perhaps you should try a C compiler instead.

If you want to carry on with a C++ compiler then you are going to have to
add a cast

v = (char*)malloc( strlen(var) + strlen(val) + 2 );

john
Jul 22 '05 #2
George Bell wrote:
The compiler(gcc) gives me this error

faxGettyApp.c++:596: ANSI C++ forbids implicit conversion from `void *' in
assignment
make[3]: *** [faxGettyApp.o] Error 1
There is no implicit conversion from 'void*' to 'char*' in C++. If your
code depends on such conversion, you have to do it explicitly.
on this code

void
faxGettyApp::setEnvVar(char* var, char* val)
{
char * v;
596 v = malloc( strlen(var) + strlen(val) + 2 );
if ( v == NULL )
traceServer("runGetty: setEnvVar: cannot malloc" );
else
{
sprintf( v, "%s=%s", var, val );
if ( putenv( v ) != 0 )
traceServer("runGetty: putenv: putenv failed" );
}
}


--
Best regards,
Andrey Tarasevich

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin Slingsby | last post by:
Anyone who can decipher this error message? What is PHP trying to tell me? exception 'MysqlException' in /var/www/localhost/htdocs/phenixsp/include/DB.inc:72 Stack trace: #0...
4
by: Larry R Harrison Jr | last post by:
I have an Access 2000/XP with an unusual autonumber scheme; I can't figure out how it generates its very unique value. I have the database temporarily located at this website: ...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
1
by: Saper\(ek\) | last post by:
I need to encrypt some data in my program, so I've created 2 functions to encrypt and decrypt data. I've created a simple program to test it, and... it crashes. It wors ok on XP, but on win98 it...
88
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
20
by: lovecreatesbeauty | last post by:
Hello experts, Is the following code snippet legal? If it is, how can exit() do the keyword return a favor and give a return value to the main function? Can a function call (or only this...
49
by: JohnQ | last post by:
There must be something at the implementation level that makes the standard disallow constructors in PODs (?). What is that? Don't most implementations just break out the constructor member...
6
by: Solo.Wolve | last post by:
I've just finished the K&R c, And begin to study c++ myself,so can anyone give me some advice?such as some books to read,and something to notice? Thank you very much.
4
by: slurpz | last post by:
I'm trying to make a simple program that will convert to and from a cipher that's already set. foo = 'a = hz\nb = ye\nc = uo\nd = pd\ne = qi\nf = jy\ng = ru\nh = sw\ni = ln\nj = ae\nk = na\nl =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.