File: c_f_tests_driver.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (66 lines) | stat: -rw-r--r-- 1,724 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extern void abort(void);

typedef struct myCDerived
{
   int cInt;
   double cDouble;
   float cFloat;
   short cShort;
   void *ptr;
}myCDerived_t;

#define DERIVED_ARRAY_LEN 10
#define ARRAY_LEN_2 3
#define DIM1 2
#define DIM2 3

void testDerivedPtrs(myCDerived_t *cDerivedPtr,
                     myCDerived_t *derivedArray, int arrayLen,
                     myCDerived_t *derived2d, int dim1, int dim2);

int main(int argc, char **argv)
{
   myCDerived_t cDerived;
   myCDerived_t derivedArray[DERIVED_ARRAY_LEN];
   myCDerived_t derived2DArray[DIM1][DIM2];
   int i = 0;
   int j = 0;

   cDerived.cInt = 1;
   cDerived.cDouble = 2.0;
   cDerived.cFloat = 3.0;
   cDerived.cShort = 4;
/*    cDerived.ptr = NULL; */
   /* nullify the ptr */
   cDerived.ptr = 0;

   for(i = 0; i < DERIVED_ARRAY_LEN; i++)
   {
      derivedArray[i].cInt = (i+1) * 1;
      derivedArray[i].cDouble = (i+1) * 1.0; /* 2.0; */
      derivedArray[i].cFloat = (i+1) * 1.0; /* 3.0; */
      derivedArray[i].cShort = (i+1) * 1; /* 4; */
/*       derivedArray[i].ptr = NULL; */
      derivedArray[i].ptr = 0;
   }

   for(i = 0; i < DIM1; i++)
   {
      for(j = 0; j < DIM2; j++)
      {
         derived2DArray[i][j].cInt = ((i*DIM1) * 1) + j;
         derived2DArray[i][j].cDouble = ((i*DIM1) * 1.0) + j;
         derived2DArray[i][j].cFloat = ((i*DIM1) * 1.0) + j;
         derived2DArray[i][j].cShort = ((i*DIM1) * 1) + j;
/*          derived2DArray[i][j].ptr = NULL; */
         derived2DArray[i][j].ptr = 0;
      }
   }

   /* send in the transpose size (dim2 is dim1, dim1 is dim2) */
   testDerivedPtrs(&cDerived, derivedArray, DERIVED_ARRAY_LEN,
                   derived2DArray[0], DIM2, DIM1);
   
   return 0;
}/* end main() */