Re: How to retrieve data from array of pointers or from a struct?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pawel Dziepak

    Re: How to retrieve data from array of pointers or from a struct?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Victor wrote:
    <snip>
    unsigned long long seed = *(dataPatternPt r + 2); // This one
    works during compile
    unsigned long long seed = *(dataPatternPt r + i); // *********
    ERROR ****** But why does this one not work?
    You are using an array of pointers not an array of long long values.
    Don't forget that sizeof(long long) != sizeof(long long*). See below for
    more description.
    /projects/svdc/aurora.validati on/work/vhnguyen/aurora_validati on/uboot/
    examples/zzzmain.c:295: undefined reference to `memcpy'
    make[1]: *** [zzzmain] Error 1
    >
    >
    Does anyone know why? It seems memcpy is not found in #include files
    but what library memcpy should reside in?
    It looks like you are not linking your output binaries with the standard
    C library in which memcpy is placed, are you? You for sure changed
    default stettings of your compiler/linker thus it's off topic for clc.
    struct key {
    unsigned long long *pattern;
    } dataPattern[] = {
    0x0000000000000 000LL,
    0xFFFFFFFFFFFFF FFFLL,
    0x5555555555555 555LL,
    0xAAAAAAAAAAAAA AAALL,
    0xCCCCCCCCCCCCC CCCLL,
    0x3333333333333 333LL,
    0xEEEEEEEEEEEEE EEELL,
    0x7777777777777 777LL,
    0x0000000000000 001LL,
    0xFFFFFFFFFFFFF FFELL,
    0xABCDEF0123456 789LL
    };
    >
    Actually I also have another 3rd question indicated below:
    >
    int sizeOfStruct = sizeof(struct key); // Here size is 4 bytes
    int totalSize = sizeof(dataPatt ern); //Here sizeof returns
    number bytes (44) . Question: Should it return 88 bytes (11 patterns
    * 8 bytes each) instead of 44 ?
    Structure key consist of a *pointer* to long long. Despite the fact long
    long appears to be 8 bytes on your architecture, you have 4 byte long
    pointers. You should use "unsigned long long pattern;" (not a pointer).

    Pawel Dziepak
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.9 (GNU/Linux)
    Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

    iEYEARECAAYFAkk WuMYACgkQPFW+cU iIHNpUuACgkiudu CUE8jj/Z0GRra1TAOUi
    SacAnjNhBJK3VUt r1NIsCqRW34PVfp V0
    =FBnj
    -----END PGP SIGNATURE-----
Working...