•Subject: Re: Struggling with API QDFRTVFD

Frank Kolmann <[email protected]>
Newsgroups gmane.comp.lang.as400.c
Message-ID <CAB-SQvji2he7fVOpfgcEq=ZN+Nfd5YMGih+c7KZcvzFcq4r87w@mail.gmail.com>
•Subject: Re: Struggling with API QDFRTVFD





 Hi Barbara



You are a gem.  Thanks for the lesson, I am still a C beginner, I admit.

I did not know how to cast types to a different type, wow.

Thanks again.



Frank





> •From: Barbara Morris <bmorris@xxxxxxxxxx>

> •Date: Tue, 19 Aug 2014 19:34:48 -0400

>p_QDFFBASE + p_QDFFBASE->WDFFINOF

> says to add the offset p_QDFFBASE->WDFFINOF to the pointer p_QDFFBASE.

>In C, when you add an offset, say 5, to a pointer, it doesn't add 5 bytes
to the pointer,

>it adds 5 multiples of the type of the pointer.

>So if p_QDFFBASE is a pointer to a structure of length 32,

>adding 5 to the pointer would actually add 5*32 bytes.

>

>(char *) p_QDFFBASE

>means to interpret p_QDFFBASE as a pointer to char,

>no matter what type p_QDFFBASE actually is.

>This forces the addition of the offset to be in bytes.

>

>(QDFFINFO_t *) casts the resulting pointer to be a pointer to a QDFFINFO_t
structure,

>which allows it to be assigned to p_QDFFINFO.

>

>So the whole thing means to take the p_QDFFBASE pointer,

>add p_QDFFBASE->WDFFINOF bytes to it, and assign it to p_QDFFINFO.



>>On 2014-08-19 09:10, Frank Kolmann wrote:

>>also I must admit I dont really know what this code means

>> p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);

>> I know it sets a pointer to the data but what does

>> (QDFFINFO_t *)((char *) mean ?



>•From: Barbara Morris <bmorris@xxxxxxxxxx>

>•Date: Tue, 19 Aug 2014 19:44:46 -0400

>The CZM0280 is telling you that you can't pass a char where a const char *
is wanted.

>

>The reason that WDFARFNM works in the strncmp is that WDFARFNM is a char
array,

>aka char *. WDFFFIOA is just a char.

>So as Scott says, you can just compare it directly to 0x01.

>>This is an example of the compile error I am getting.

>> 218 17 | if (strncmp(p_QDFFFINF->WDFFFIOA, Attrib, 1) == 0)

>> *=SEVERE==========> a - CZM0280 Function argument assignment between
types

>> "const char*" and "char" is not allowed.

>> ...

>> However there are other uses of strncmp in the program that compile just
fine.
-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.