Re: copy structure to unsigned char



Ravi wrote:

Hi,

I need to copy a nested structure (structures having multiple
structures) into a unsigned char
array. I cannot use memcpy as our micro doesnt support it.
Huh? Truly?
I know the way to do is field by field copy of each structure members,
but then is there a
general algo / code which does this field by field copy ???? (Should
not have padding bytes)

My sample structure looks like this ->

struct temp {

struct t1;
struct t2;
struct t3;
..
..
char f[10];
};

I would be grateful if anybody shares me a generic code to do the
above,.

thanks
ravi
Perhaps you could ask in a group that addresses the language or your micro
OS.
If it is C can you not do it by casting?
const unsigned char *p = (unsigned char *)(&mytemp);
--
Bill Medland
.



Relevant Pages

  • copy structure to unsigned char
    ... structures) into a unsigned char ... I cannot use memcpy as our micro doesnt support it. ... struct temp { ... I would be grateful if anybody shares me a generic code to do the ...
    (comp.programming)
  • [git] m68k
    ... static volatile struct baboon *baboon; ... +static unsigned char baboon_disabled; ... -void baboon_irq_enable(int irq) { ... int baboon_irq_pending ...
    (Linux-Kernel)
  • Re: [RFC] [PATCH 1/1] input/touchscreen: Synaptics Touchscreen Driver
    ... Initial driver for Synaptics touchscreens using RMI4 protocol. ... +struct rmi_function_descriptor { ... unsigned char commandBaseAddr; ...
    (Linux-Kernel)
  • [patch v1.2.35] WAN: add driver retina
    ... static unsigned int find_cnt; ... struct fepci_card_private *cp) ... goto INVALID; ... (unsigned char __user *) ...
    (Linux-Kernel)
  • Re: structure padding
    ... > aggregate data types in order to access the members of the aggregate ... > struct { ...
    (comp.lang.c)