Passing array of struct 
Author Message
 Passing array of struct

I am getting two warnings when I am passing an array of struct to a
function.  Defined as below:

Warnings:
warning C4047: 'function' : 'struct tfwZoneTag ** ' differs in levels of
indirection from 'struct tfwZoneTag (*)[256]'
warning C4024: 'getZoneInfo' : different types for formal and actual
parameter 2

Here's the other necessary info:

typedef struct tfwZoneTag
{
    char szBlah[8];

Quote:
} tfwZoneList;

tfwZoneList   tfwZone[256];

header info:
int getZoneInfo(FILE *, tfwZoneList *[]);

function call:
i = getZoneInfo(fpZone, &tfwZone);

function:
int getZoneInfo(FILE *fpZone, tfwZoneList *CTfwZone[])
{...}

If anyone has ideas as to how I can fix this please let me know.  I am
modifying the structure inside of the function.

TIA
isis98

--== Sent via Deja.com http://www.*-*-*.com/
---Share what you know. Learn what you don't.---



Sat, 27 Oct 2001 03:00:00 GMT  
 Passing array of struct

Quote:

> I am getting two warnings when I am passing an array of struct to a
> function.  Defined as below:

> Warnings:
> warning C4047: 'function' : 'struct tfwZoneTag ** ' differs in levels
of
> indirection from 'struct tfwZoneTag (*)[256]'
> warning C4024: 'getZoneInfo' : different types for formal and actual
> parameter 2

> Here's the other necessary info:

> typedef struct tfwZoneTag
> {
>     char szBlah[8];
> } tfwZoneList;

> tfwZoneList   tfwZone[256];

> header info:
> int getZoneInfo(FILE *, tfwZoneList *[]);

                          ^^^^^^^^^^^^^^^
This is declaring an array of pointers to tfwZoneList, *not* a pointer
to an array - for that you need to use:
(1)
  int getZoneInfo(FILE *, tfwZoneList (*)[]);

However, since arrays decay to pointers in argument lists, you can just
use:
(2)
  int getZoneInfo(FILE *, tfwZoneList []);

Quote:

> function call:
> i = getZoneInfo(fpZone, &tfwZone);

If you use (2) from the above, then taking the address is unnecessary:
(2a)
  i = getZoneInfo(fpZone, tfwZone);

Quote:

> function:
> int getZoneInfo(FILE *fpZone, tfwZoneList *CTfwZone[])
> {...}

> If anyone has ideas as to how I can fix this please let me know.  I
am
> modifying the structure inside of the function.

> TIA
> isis98

> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

--
Tristan Styles #1485

Failure is not an Option
It is Standard Operating Procedure

--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---



Sun, 28 Oct 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing array of struct to dll (again)

2. array of Struct passing into a function

3. Array of struct pass to function

4. How to pass a struct to an unsigned char array

5. Passing a struct with an array to C++ function

6. passing adress of second element in array of structs

7. How to pass a struct to an unsigned char array

8. pass a pointer to array of structs to functions

9. Passing an array of structs

10. Passing an array of structs

11. passing arrays and returning structs

12. Passing structs and arrays --- marshaling and IDL issues...

 

 
Powered by phpBB® Forum Software