2011-03-20 19:18:19 +01:00
|
|
|
/****************************************************************************
|
2021-06-16 09:22:16 +02:00
|
|
|
* apps/examples/nxflat/tests/struct/struct_main.c
|
2011-03-20 19:18:19 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2011-03-20 19:18:19 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-03-20 19:18:19 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2011-03-20 19:18:19 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "struct.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-04-14 00:24:28 +02:00
|
|
|
const struct struct_dummy_s dummy_struct =
|
2011-03-20 19:18:19 +01:00
|
|
|
{
|
|
|
|
DUMMY_SCALAR_VALUE3
|
|
|
|
};
|
|
|
|
|
|
|
|
int dummy_scalar = DUMMY_SCALAR_VALUE2;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2014-02-11 02:11:56 +01:00
|
|
|
const struct struct_s *mystruct;
|
2011-03-20 19:18:19 +01:00
|
|
|
|
|
|
|
printf("Calling getstruct()\n");
|
|
|
|
mystruct = getstruct();
|
|
|
|
printf("getstruct returned %p\n", mystruct);
|
|
|
|
printf(" n = %d (vs %d) %s\n",
|
|
|
|
mystruct->n, DUMMY_SCALAR_VALUE1,
|
|
|
|
mystruct->n == DUMMY_SCALAR_VALUE1 ? "PASS" : "FAIL");
|
|
|
|
|
|
|
|
printf(" pn = %p (vs %p) %s\n",
|
|
|
|
mystruct->pn, &dummy_scalar,
|
|
|
|
mystruct->pn == &dummy_scalar ? "PASS" : "FAIL");
|
|
|
|
if (mystruct->pn == &dummy_scalar)
|
|
|
|
{
|
|
|
|
printf(" *pn = %d (vs %d) %s\n",
|
|
|
|
*mystruct->pn, DUMMY_SCALAR_VALUE2,
|
|
|
|
*mystruct->pn == DUMMY_SCALAR_VALUE2 ? "PASS" : "FAIL");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" ps = %p (vs %p) %s\n",
|
|
|
|
mystruct->ps, &dummy_struct,
|
|
|
|
mystruct->ps == &dummy_struct ? "PASS" : "FAIL");
|
|
|
|
if (mystruct->ps == &dummy_struct)
|
|
|
|
{
|
|
|
|
printf(" ps->n = %d (vs %d) %s\n",
|
|
|
|
mystruct->ps->n, DUMMY_SCALAR_VALUE3,
|
|
|
|
mystruct->ps->n == DUMMY_SCALAR_VALUE3 ? "PASS" : "FAIL");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" pf = %p (vs %p) %s\n",
|
|
|
|
mystruct->pf, dummyfunc,
|
|
|
|
mystruct->pf == dummyfunc ? "PASS" : "FAIL");
|
|
|
|
if (mystruct->pf == dummyfunc)
|
|
|
|
{
|
|
|
|
printf("Calling mystruct->pf()\n");
|
|
|
|
mystruct->pf();
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Exit-ing\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dummyfunc(void)
|
|
|
|
{
|
|
|
|
printf("In dummyfunc() -- PASS\n");
|
|
|
|
}
|