473,378 Members | 1,389 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,378 software developers and data experts.

C4047 warning in a project

This warning keeps popping up...

box.c(50) : warning C4047: '=' : 'box *' differs in levels of indirection from 'size_t'

49 pBox = malloc(sizeof(box)*lineCount-1);
50 assert(pBox = (sizeof(box)*lineCount-1));


typedef struct
{
double width;
double length;
double height;
double weight;
double volume;
char contents[32];
} box;

box box1[10] = {0};
box* pBox = box1;

here is my declaration and the problem with the allocation. I needed to read in from a file assign the text to an array of structs and dynamically allocate memory for the array.
Nov 20 '07 #1
2 1878
oler1s
671 Expert 512MB
assert(pBox = (sizeof(box)*lineCount-1));
Ehhh? pBox is a pointer. sizeof.... gets you a size_t value, which is comparable to a long int or the like. It's basically an unsigned integral value. See the problem in your assertion? If you want to check if malloc worked, check if pBox is NULl after the call to malloc. If so, malloc failed.
Nov 20 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
50 assert(pBox = (sizeof(box)*lineCount-1));
You have fallen victim to decay of array. That is, from a pointer's point of view, all you have is an address. The number of elements has been lost. You have to remember that manually.
Nov 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: isxyos | last post by:
Hello, It's just a warning, but can anybody explain to me what this warning is: warning C4047: '=' : 'unsigned int ' differs in levels of indirection from 'void *' #include <stdio.h> void...
0
by: Peter | last post by:
Hi, I've been recently porting some software written under VC++ 6.0 to VC .NET. The software was compiling fine under 6.0 but under .NET I'm getting linker warning: b.obj : warning LNK4227:...
1
by: Raed Sawalha | last post by:
when i build asp.net application i have theses warnings messages ,what they mean? Preparing resources... Updating references... Warning: The dependency 'EW_Calender, Version=2.5.2055.20123,...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
10
by: moondaddy | last post by:
I converted a vb.1.1 web service project to 2.0 and .net 2.0 created / replace some datasets. The code it automatiacly generated gets a warning message as follows: Warning 150 Name...
3
by: Chuck Cobb | last post by:
I'm doing a CSharp project in VS2005 and I'm getting some strange warning messages. The problem is that the warning messages don't link to anything in my code so they are very difficult to track...
5
by: pkirk25 | last post by:
I like to keep warnings to a minimum and am find this one cropping up a lot. struct auction_bargains bargainList; struct auction_bargains *pBargainList = &bargainList; I am creating an array...
4
by: Sam Tan | last post by:
Hello got two warning when compiling , the .exe file works fine with these warning but i prefer to get rid of them :) if anyone can point me to a general website for indirection warnings that...
3
by: harrym55 | last post by:
Hi, I receive warning for the following enum: Public Enum enumMinOrMax Min Max End Enum Warning 20 Type of parameter 'MinOrMax' is not CLS-compliant.
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: 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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.