how to handle the compile error when the production code will include a purged linux kernel library?

1,316 views
Skip to first unread message

xiaohong liu

unread,
Aug 4, 2011, 5:01:07 AM8/4/11
to cpputest
HI,

Our embedded C code is using a linux kernel purged by us, and this is
problem on how to deal with legacy code. I'm just try to
makeitcompile. I post the details what I did below, Could you be so
kind to give some suggestion? thanks a lot.

#uname -a
Linux cnbjc0050 2.6.16.60-0.21-smp #1 SMP Tue May 6 12:41:02 UTC 2008
x86_64 x86_64 x86_64 GNU/Linux

--------------------------------------------------------------------
In test code Hu_drvTest.cpp,
extern "C"
{
#include "ont_hal.h"
}
-----------------------------------------------------------------
In ont_hal.h, it will
#include <linux/list.h>
#include <linux/semaphore.h>
---------------------------------------------------------------------------
then I run make test, here is the error:
In file included from /PROJECT_PATH/drvs/include/ont_hal.h:4,
from Hu_drvTest.cpp:3:
/usr/include/linux/list.h:814:2: warning: #warning "don't include
kernel headers in userspace"
In file included from Hu_drvTest.cpp:3:
PROJECT_PATH/drvs/include/ont_hal.h:5:29: warning: linux/semaphore.h:
No such file or directory
PROJECT_PATH/drvs/include/ont_hal.h:10: error: field 'list' has
incomplete type
PROJECT_PATH/drvs/include/ont_hal.h:13: error: field 'sem' has
incomplete type
PROJECT_PATH/drvs/include/ont_hal.h:23: error: field 'node' has
incomplete type
-----------------------------------------------------------------------------------------------------------------------------------------------------
Okay, I realize our code is using a specific purged kernel
PROJECT_PATH/linux-2.6.34.6/, which has linux-2.6.34.6/include/linux/
semaphore.h &list.h
so I update the INCLUDE_DIRS in Makefile for the test code to include
the path linux-2.6.34.6/include/linux.
then I met the size_t error...

here are the top lines of error:
make[1]: Entering directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
test/drvs/hal'
Making clean
compiling AllTests.cpp
/usr/include/stdlib.h:140: error: 'size_t' does not name a type
/usr/include/bits/time.h:69: error: redefinition of 'struct timeval'
PROJECT_PATH/linux-2.6.34.6/include/linux/time.h:20: error: previous
definition of 'struct timeval'
/usr/include/stdlib.h:455: error: 'size_t' has not been declared
/usr/include/stdlib.h:485: error: 'size_t' has not been declared
/usr/include/stdlib.h:589: error: 'size_t' was not declared in this
scope
/usr/include/stdlib.h:589: error: expected ',' or ';' before 'throw'
/usr/include/stdlib.h:591: error: 'size_t' was not declared in this
scope
/usr/include/stdlib.h:591: error: 'size_t' was not declared in this
scope
.................

--------------------------------------------------------------------------------------
for convenienc, I post our purged stddef.h here
#ifndef
_LINUX_STDDEF_H
#define _LINUX_STDDEF_H

#include <linux/compiler.h>

#undef
NULL
#if defined(__cplusplus)
#define NULL
0
#else
#define NULL ((void
*)0)
#endif

#ifdef __KERNEL__

enum {
false = 0,
true = 1
};

#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#endif /* __KERNEL__ */

#endif


I also have question that when we have such a customized kernel,
should we compile our code based on this library and take the MACROS
used when compile the production code?

thanks a lot
Xiaohong Liu


xiaohong liu

unread,
Aug 4, 2011, 6:28:18 AM8/4/11
to cpputest
I'm confused. The purged linux kernel is for powerpc, and supposed to
run on embedded system. So I think we should not run UT based on the
purged linux kernel.Right?


If answer is yes, I should not add purged linux kernel path into
TEST_DIRS,But How can I exclude the impact brought by the code in
ont_hal.h which includes the two system header?
Go back to the errors at the beginning:
1. list.h & semaphore.h
How do I stop UT to calling /usr/inlcude/linux/list.h? this list.h may
introduce something I don't want.
through set CPPUTEST_USE_STD_CPP_LIB = N?


2. for the errors:
PROJECT_PATH/drvs/include/ont_hal.h:10: error: field 'list' has
incomplete type
PROJECT_PATH/drvs/include/ont_hal.h:13: error: field 'sem' has
incomplete type
PROJECT_PATH/drvs/include/ont_hal.h:23: error: field 'node' has
incomplete type

part of ont_hal.h src:
9 struct hal_list{
10 struct list_head list;
11 unsigned char name[HAL_NAME_LEN + 1];
12 int hal_count;
13 struct semaphore sem;
14 int created;
15 };

So here the solution is that I update /CppUTest/include/Platforms/Gcc/
platform.h through copying struct list_head and semaphore from purged
linux kernel header files?

thanks
Xiaohong

Terry Yin

unread,
Aug 4, 2011, 7:50:43 AM8/4/11
to cppu...@googlegroups.com
Hi,

is your project a kernel module? How do you compile the production code?

My experience is that kernel headers are hard to be included in the user mode. It will be much easier if you:
1. write your tests in c functions using the checks provided by cpputest.
2. compile the testing c code using kernel mode into a .ko file.
3. Call the c test functions from .cpp cpputest tests. and compile the .cpp into .o
4. stub all the kernel calls.
5. link the production .ko, the test .ko, and the test .o files into user mode test executables. (it's ok to link a .ko to .o as long as you have all the stubs.)

I guess you might want to run your tests on target too. I'm not sure if cpputest is capable to do that now. Perhaps that's something cpputest could improve.

I hope this helps:-)

terry
--
-terry
-------------------------
Blog: http://terryyin.blogbus.com/
twitter: http://twitter.com/terryyin

Bas Vodde

unread,
Aug 4, 2011, 10:03:50 PM8/4/11
to cppu...@googlegroups.com

Hiya,

Interesting :)

I'll do my best to answer your mail, though it won' t be easy as I don't have the same kernel here. Yin Zhe already gave an answer based on his earlier experience. I'll explain his answer a bit more after trying to answer the things you mentioned.

1. list and sem

You *do* need to use the CPPUTEST_USE_STD_LIB=N for sure. Otherwise you'll get the STL list and that will definitively conflict.

You can avoid the /usr/include/linux/list.h to be included by adding the -nostdinc parameter. However, adding this parameter might lead to some compilation errors in CppUTest. I guess that you can fix these by adding the /usr/include back to your include path, but *after* your other path.

Doing this *might* still lead to compile errors in the PlatformSpecific functions. If it does, you'll probably need to write a new GccPlatform.cpp, but I'm not sure. Give it a try to add the -nostdcinc

2. Standard C

So, the main problem you're having is with Standard C library dependencies what aren't the same. Now, this is actually less of a problem than most would expect. CppUTest is trying to separate Standard C library out so that it can work without the Standard C library. However, there are 3 dependencies that we decided to keep and one of them seems to be a problem for you. The 3 include dependencies to StdC are in TestHarness.h and are:

stdarg: This needs to be included for using variable argument lists, which are used in SimpleString.
stddef: This is needed for size_t which is used in malloc
stdlib: This is needed for malloc, which needs to be included before overriding it

I think it wouldn't be too hard to make a -NOSTDC option to CppUTest, not sure if that would be the main problem though. So, could you check if it works with the above changes in path.

------------

The solution that Terry mentioned also can resolve this, but it is more work. He suggests to write the tests in C itself. This is currently some additional work though, it would work list this;

In CppWrapperTest.cpp

extern "C" {
#include "myTestsInC.h"
}

TEST_GROUP(CppWrapperTest)
{
};

TEST(CppWrapperTest, test_name)
{
test_in_c_with_name(parameters);
}

Then the myTestsInC.h would be:

extern void test_in_c_with_name(parameters);

Then you can have the myTestsInC.c with:

#include "CppUTest/TestHarness_c.h"

void test_in_c_with_name(parameters)
{
// Use the C style macros rather than the C++ style
}

With this, you can compile the myTestsInC.h with the -nostdinc and link it to CppUTest ;)

Now, this is a huge amount of extra work, so I'd prefer the first solution. I've been thinking of adding this code generation to enable writing the tests in C only, but I'm not sure if it is worth it....

Hope this helps.

Thanks,

Bas

xiaohong liu

unread,
Aug 5, 2011, 2:47:29 AM8/5/11
to cpputest
Hi, All

really thanks a lot!

Firstly, let's see what's current result.
My setting:
- CPPUTEST_USE_STD_LIB=N
- INCLUDE_DIRS =\
$(KERNELDIR)/include/linux/ \ <---- this is our
purge linux kernel

Make test result:

make[1]: Entering directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
test/drvs/hal'
Making clean
compiling AllTests.cpp
/usr/include/stdlib.h:140: error: ‘size_t’ does not name a type
/usr/include/bits/time.h:69: error: redefinition of ‘struct timeval’
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:20: error: previous definition of ‘struct timeval’
/usr/include/stdlib.h:455: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:485: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:589: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:589: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:591: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:591: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:591: error: initializer expression list treated
as compound expression
/usr/include/stdlib.h:592: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:600: error: ‘size_t’ has not been declared
/usr/include/alloca.h:33: error: ‘size_t’ was not declared in this
scope
/usr/include/alloca.h:33: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:617: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:617: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:622: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:622: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:779: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:779: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:784: error: ‘size_t’ has not been declared
/...................

$(KERNELDIR)/include/linux/stddef.h has been modified without size_t
typedef. size_t is defined in another file types.h


And then Let's come back how to make all the project. Without UT, we
will:
1. get a customized gcc/g++ compiler
2. compile a customized linux kernel with the customized compiler.
3. compile production code based on the customized linux kernel with
the customized compiler.

I want to know when add UT to the project, if it's right for me to do
like that:
1. still compile production code based on the customized linux kernel
with the customized compiler --->production.ko
2. Code under test is within production code and is compile along with
production code -->CUT.ko
2. Since ComponentTest.cpp Test case will call CUT and finally include
purged linux kernel, we need to compile ComponentTest.cpp with gcc <--
I think I just need to include purged linux kernel dirs
3. stub system call necessary in MOCK_DIR with gcc --> stub.o
4. once compile pass, then try link them all.

thanks
Xiaohong Liu

Bas Vodde

unread,
Aug 5, 2011, 2:55:10 AM8/5/11
to cppu...@googlegroups.com

Hiya,

> Firstly, let's see what's current result.
> My setting:
> - CPPUTEST_USE_STD_LIB=N
> - INCLUDE_DIRS =\
> $(KERNELDIR)/include/linux/ \ <---- this is our
> purge linux kernel

Did you still added the -nostdinc compiler option also. If I look at the below compiler errors, it seems like it still finds the stdlib.h from the /usr/include and not from your own location.

>
> Make test result:
>
> make[1]: Entering directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
> test/drvs/hal'
> Making clean
> compiling AllTests.cpp
> /usr/include/stdlib.h:140: error: ‘size_t’ does not name a type
> /usr/include/bits/time.h:69: error: redefinition of ‘struct timeval’
> /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
> time.h:20: error: previous definition of ‘struct timeval’
> /usr/include/stdlib.h:455: error: ‘size_t’ has not been declared
> /usr/include/stdlib.h:485: error: ‘size_t’ has not been declared
> /usr/include/stdlib.h:589: error: ‘size_t’ was not declared in this
> scope

<snip>

> And then Let's come back how to make all the project. Without UT, we
> will:
> 1. get a customized gcc/g++ compiler
> 2. compile a customized linux kernel with the customized compiler.
> 3. compile production code based on the customized linux kernel with
> the customized compiler.

Oki. What is the reason fo rthe customized compiler? Is it just to output different binaries or does it also change the language?

> I want to know when add UT to the project, if it's right for me to do
> like that:
> 1. still compile production code based on the customized linux kernel
> with the customized compiler --->production.ko
> 2. Code under test is within production code and is compile along with
> production code -->CUT.ko
> 2. Since ComponentTest.cpp Test case will call CUT and finally include
> purged linux kernel, we need to compile ComponentTest.cpp with gcc <--
> I think I just need to include purged linux kernel dirs
> 3. stub system call necessary in MOCK_DIR with gcc --> stub.o
> 4. once compile pass, then try link them all.

Yah, this seems about right, except that I would probably not use the customized compiler. I assume the customized compiler creates target binary code and thus you can't actually execute it on your development environment. If you can get the normal compiler to compile the same code, then you ought to be able to execute the tests on your development environment.

Does that make sense? Good luck!

Bas

xiaohong liu

unread,
Aug 5, 2011, 3:14:00 AM8/5/11
to cpputest


On Aug 5, 2:55 pm, Bas Vodde <b...@odd-e.com> wrote:
> Hiya,
>
> > Firstly, let's see what's current result.
> > My setting:
> >       - CPPUTEST_USE_STD_LIB=N
> >       -  INCLUDE_DIRS =\
> >                 $(KERNELDIR)/include/linux/ \       <---- this is our
> > purge linux kernel
>
> Did you still added the -nostdinc compiler option also. If I look at the below compiler errors, it seems like it still finds the stdlib.h from the /usr/include and not from your own location.
sorry. I add this option to $(CPPUTEST_HOME)/build/MakefileWorker.mk
and do it again. here is the result.

result of make flags:
Compile C and C++ source with CPPFLAGS:
-g
-nostdinc
-DCPPUTEST_STD_CPP_LIB_DISABLED
-fprofile-arcs
-ftest-coverage
-pedantic-errors
-Wall
-Wextra
-Wshadow
-Wswitch-default
-Wswitch-enum
-Wconversion
-I.
-I/home/edgijlq/UnitTestFramework/CppUTest/include

Compile C++ source with CXXFLAGS:
-nostdinc++
-include
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNe wMacros.h

Compile C source with CFLAGS:
-include
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMa llocMacros.h

Link with LDFLAGS:

Link with LD_LIBRARIES:
-lstdc++
-lgcov

Create libraries with ARFLAGS:
rv


make result:
Making clean
compiling AllTests.cpp
In file included from <command line>:1:
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:28:20: warning: stdlib.h: No such file
or directory
In file included from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/Utest.h:34,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:71,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from AllTests.cpp:28:
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:41:20: warning: stdarg.h: No such file or directory
In file included from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/SimpleString.h:42,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/Utest.h:34,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:71,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from AllTests.cpp:28:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
stddef.h:4:28: warning: linux/compiler.h: No such file or directory
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: declaration of ‘operator new’
as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: ‘size_t’ was not declared in
this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: expected primary-expression
before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: expected primary-expression
before ‘int’



>
>
> > Make test result:
>
> > make[1]: Entering directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
> > test/drvs/hal'
> > Making clean
> > compiling AllTests.cpp
> > /usr/include/stdlib.h:140: error: ‘size_t’ does not name a type
> > /usr/include/bits/time.h:69: error: redefinition of ‘struct timeval’
> > /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
> > time.h:20: error: previous definition of ‘struct timeval’
> > /usr/include/stdlib.h:455: error: ‘size_t’ has not been declared
> > /usr/include/stdlib.h:485: error: ‘size_t’ has not been declared
> > /usr/include/stdlib.h:589: error: ‘size_t’ was not declared in this
> > scope
>
> <snip>
>
> > And then Let's come back how to make all the project. Without UT, we
> > will:
> > 1. get a customized gcc/g++ compiler
> > 2. compile a customized linux kernel with the customized compiler.
> > 3. compile production code based on the customized linux kernel with
> > the customized compiler.
>
> Oki. What is the reason fo rthe customized compiler? Is it just to output different binaries or does it also change the language?
I don't know.... :)
>
> > I want to know when add UT to the project, if it's right for me to do
> > like that:
> > 1. still compile production code based on the customized linux kernel
> > with the customized compiler  --->production.ko
> > 2. Code under test is within production code and is compile along with
> > production code  -->CUT.ko
> > 2. Since ComponentTest.cpp Test case will call CUT and finally include
> > purged linux kernel, we need to compile ComponentTest.cpp with gcc <--
> > I think I just need to include purged linux kernel dirs
> > 3. stub system call necessary in MOCK_DIR with gcc --> stub.o
> > 4. once compile pass, then try link them all.
>
> Yah, this seems about right, except that I would probably not use the customized compiler. I assume the customized compiler creates target binary code and thus you can't actually execute it on your development environment. If you can get the normal compiler to compile the same code, then you ought to be able to execute the tests on your development environment.
---------------------------------
So it means I only use gcc to compile all production code? thanks.
> read more »

Bas Vodde

unread,
Aug 5, 2011, 3:23:56 AM8/5/11
to cppu...@googlegroups.com

Hi,

Ah good, looks like we moved a little forward.

The errors in your output seem to relate to the MemoryLeakDetection. I'm not totally clear why it gives these errors, but we can easily get rid of them by deleting the new override at the moment. You can do this by removing this option:

> -include /home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/MemoryLeakDetectorNewMacros.h

Its on line 160 in the MakefileWorker.mk. You ought to be able to define it as something else without changing the Makefile

Then, you still got warnings related to stdC library not existing anymore. Here you can try to add stdC again to the include path after your dir. You could do this by adding /usr/include to the INCLUDE_DIRS *behind* your include dir.

Hope this helps you forward again!

Bas

xiaohong liu

unread,
Aug 5, 2011, 3:26:48 AM8/5/11
to cpputest
Then I include /usr/include trying to fix the warning: stdlib.h: No
such file
or directory

make flags:

Compile C and C++ source with CPPFLAGS:
-g
-nostdinc
-DCPPUTEST_STD_CPP_LIB_DISABLED
-fprofile-arcs
-ftest-coverage
-pedantic-errors
-Wall
-Wextra
-Wshadow
-Wswitch-default
-Wswitch-enum
-Wconversion
-I.
-I/home/edgijlq/UnitTestFramework/CppUTest/include
-I/usr/include


make result:
Making clean
compiling AllTests.cpp
In file included from /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
linux-2.6.34.6/include/linux/stddef.h:4,
from /usr/include/stdlib.h:33,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/usr/include/linux/compiler.h:29:32: error: ISO C does not permit
named variadic macros
In file included from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/usr/include/sys/select.h:93:1: error: "FD_SET" redefined
In file included from /usr/include/sys/types.h:133,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:246:1: error: this is the location of the previous
definition
In file included from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/usr/include/sys/select.h:94:1: error: "FD_CLR" redefined
In file included from /usr/include/sys/types.h:133,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:247:1: error: this is the location of the previous
definition
In file included from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/usr/include/sys/select.h:95:1: error: "FD_ISSET" redefined
In file included from /usr/include/sys/types.h:133,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:248:1: error: this is the location of the previous
definition
In file included from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/usr/include/sys/select.h:96:1: error: "FD_ZERO" redefined
In file included from /usr/include/sys/types.h:133,
from /usr/include/stdlib.h:438,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakDetectorNewMacros.h:2 8,
from <command line>:1:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:249:1: error: this is the location of the previous
definition
In file included from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/Utest.h:34,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:71,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from AllTests.cpp:28:
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:41:20: warning: stdarg.h: No such file or
directory
/usr/include/stdlib.h:140: error: ‘size_t’ does not name a type
/usr/include/asm-x86_64/posix_types.h:32: error: ISO C++ does not
support ‘long long’
/usr/include/asm-x86_64/types.h:22: error: ISO C++ does not support
‘long long’
/usr/include/asm-x86_64/types.h:23: error: ISO C++ does not support
‘long long’
/usr/include/bits/time.h:69: error: redefinition of ‘struct timeval’
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
time.h:20: error: previous definition of ‘ struct timeval’
/usr/include/stdlib.h:455: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:485: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:542: error: ISO C++ does not support ‘long long’
/usr/include/stdlib.h:589: warning: ‘malloc’ initialized and declared
‘extern’
/usr/include/stdlib.h:589: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:589: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:591: warning: ‘calloc’ initialized and declared
‘extern’
/usr/include/stdlib.h:591: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:591: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:591: error: initializer expression list treated
as compound expression
/usr/include/stdlib.h:592: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:600: error: ‘size_t’ has not been declared
/usr/include/alloca.h:33: warning: ‘alloca’ initialized and declared
‘extern’
/usr/include/alloca.h:33: error: ‘size_t’ was not declared in this
scope
/usr/include/alloca.h:33: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:617: warning: ‘valloc’ initialized and declared
‘extern’
/usr/include/stdlib.h:617: error: ‘size_t’ was not declared in this
scope
/usr/include/stdlib.h:617: error: expected ‘,’ or ‘;’ before ‘throw’
/usr/include/stdlib.h:622: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:622: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:779: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:779: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:784: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:784: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:787: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:787: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:862: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:865: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:869: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:873: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:882: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:886: error: ‘size_t’ has not been declared
/usr/include/stdlib.h:893: error: ‘size_t’ does not name a type
/usr/include/stdlib.h:896: error: ‘size_t’ does not name a type
/usr/include/stdlib.h:959: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: declaration of
‘operator new’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: expected pri mary-
expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:61: error: expected pri mary-
expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:62: error: declaration of
‘operator new []’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:62: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:62: error: expected pri mary-
expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:62: error: expected pri mary-
expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:63: error: declaration of
‘operator new’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:63: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:64: error: declaration of
‘operator new []’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorNewMacros.h:64: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: warning: ‘cppute
st_malloc_location’ initialized and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: error: expected primary-
expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: error: expected primary-
expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: error: initializ er
expression list treated as compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: warning: ‘cppute
st_calloc_location’ initialized and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: ‘size_t’ was not
declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: expected primary-
expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: expected primary-
expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: initializ er
expression list treated as compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:35: error: ‘size_t’ has not
been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:54: error: ‘size_t’ has not been decla red
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:71: error: ‘size_t’ does not name a ty pe
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:77: error: ‘size_t’ has not been decla red
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:77: error: ‘size_t’ has not been decla red
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:78: error: ‘size_t’ has not been decla red
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:81: error: ‘size_t’ does not name a ty pe
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:89: error: expected ‘;’ before ‘(’ tok en
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:105: error: ‘size_t’ has not been decl ared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:107: error: ‘size_t’ does not name a t ype
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:108: error: declaration of ‘operator[] ’ as non-
function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:108: error: expected ‘;’ before ‘(’ to ken
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:113: error: ‘size_t’ does not name a t ype
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:130: error: ‘va_list’ has not been dec lared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:79: warning: ‘cpputest_malloc’ initia lized and
declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:79: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: warning: ‘cpputest_calloc’ initia lized and
declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: initializer expression lis t treated
as compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:81: error: ‘size_t’ has not been decl ared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: warning: ‘cpputest_malloc_locatio n’
initialized and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: redefinition of ‘void* cpp
utest_malloc_location’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:33: error: ‘void* cp
putest_malloc_location’ previously defined here
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: expected primary-expressio n before
‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: expected primary-expressio n before
‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: warning: ‘cpputest_calloc_locatio n’
initialized and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: error: redefinition of ‘void* cpp
utest_calloc_location’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakDetectorMallocMacros.h:34: error: ‘void* cp
putest_calloc_location’ previously defined here
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: error: ‘size_t’ was not declared in this
scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:86: error: expected primary-expressio n before
‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:86: error: expected primary-expressio n before
‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:87: error: ‘size_t’ has not been decl ared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakWarningPlugin.h:63: error: declaration of ‘ operator
new’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakWarningPlugin.h:63: error: ‘size_t’ was not declared
in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakWarningPlugin.h:64: error: declaration of ‘ operator
new []’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
MemoryLeakWarningPlugin.h:64: error: ‘size_t’ was not declared
in this scope
> ...
>
> read more »

xiaohong liu

unread,
Aug 5, 2011, 3:34:04 AM8/5/11
to cpputest
Hi,

I prefer to disable memory leak detector. So I set
CPPUTEST_USE_MEM_LEAK_DETECTION = N.


edgijlq@cnbjc0050:~/T063GMIII_VOBS/ONT_SW_bba/test/drvs/hal> make
flags

Compile C and C++ source with CPPFLAGS:
-DCPPUTEST_MEM_LEAK_DETECTION_DISABLED
-g
-nostdinc
-DCPPUTEST_STD_CPP_LIB_DISABLED
-fprofile-arcs
-ftest-coverage
-pedantic-errors
-Wall
-Wextra
-Wshadow
-Wswitch-default
-Wswitch-enum
-Wconversion
-I.
-I/home/edgijlq/UnitTestFramework/CppUTest/include
-I/usr/include

Compile C++ source with CXXFLAGS:
-nostdinc++

Compile C source with CFLAGS:

Link with LDFLAGS:

Link with LD_LIBRARIES:
-lstdc++
-lgcov

Create libraries with ARFLAGS:
rv

here is the make result
--------------------------------------------
make[1]: Entering directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
test/drvs/hal'
Making clean
compiling AllTests.cpp
In file included from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/Utest.h:34,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:71,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from ./AllTests.cpp:28:
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:41:20: warning: stdarg.h: No such file or directory
In file included from /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
linux-2.6.34.6/include/linux/stddef.h:4,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/SimpleString.h:42,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/Utest.h:34,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:71,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from ./AllTests.cpp:28:
/usr/include/linux/compiler.h:29:32: error: ISO C does not permit
named variadic macros
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:54: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:71: error: ‘size_t’ does not name a type
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:77: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:77: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:78: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:81: error: ‘size_t’ does not name a type
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:89: error: expected ‘;’ before ‘(’ token
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:105: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:107: error: ‘size_t’ does not name a type
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:108: error: declaration of ‘operator[]’ as non-function
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:108: error: expected ‘;’ before ‘(’ token
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:113: error: ‘size_t’ does not name a type
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
SimpleString.h:130: error: ‘va_list’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:79: warning: ‘cpputest_malloc’ initialized and
declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:79: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: warning: ‘cpputest_calloc’ initialized and
declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:80: error: initializer expression list treated as
compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:81: error: ‘size_t’ has not been declared
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: warning: ‘cpputest_malloc_location’ initialized
and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: expected primary-expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: expected primary-expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:84: error: initializer expression list treated as
compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: warning: ‘cpputest_calloc_location’ initialized
and declared ‘extern’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:85: error: ‘size_t’ was not declared in this scope
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:86: error: expected primary-expression before ‘const’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:86: error: expected primary-expression before ‘int’
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:86: error: initializer expression list treated as
compound expression
/home/edgijlq/UnitTestFramework/CppUTest/include/CppUTest/
TestHarness_c.h:87: error: ‘size_t’ has not been declared
make[1]: *** [objs/./AllTests.o] Error 1
make[1]: Leaving directory `/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
test/drvs/hal'



-----------------------------------------------------
> ...
>
> read more »

Bas Vodde

unread,
Aug 5, 2011, 3:34:38 AM8/5/11
to cppu...@googlegroups.com

Whoa :)

Oki, that doesn't look good! Better remove that again and try to do without Standard C for now. I think you might need to figure out how to deal with standard C calls later. Probably your linux kernel code has C headers, so perhaps you could find the C headers in there and then not use the local ones.

I did noticed you did not remove the -include option yet from the Makefile options. I'd do that also, just to create less code.

There are two ways you can proceed with this:

1) The way Terry suggested earlier. Seperate the compilation of the tests so you can easily include the kernel headers
2) Continue this way. This might be harder for now, but perhaps we can do some of these changes in the CppUTest code to make it easier in the future for working on kernel code.

Bas

Bas Vodde

unread,
Aug 5, 2011, 3:36:53 AM8/5/11
to cppu...@googlegroups.com

Hi,

Oki, looks good. I guess from here it would be best to throw out the /usr/include again and instead provide the 3 missing headers yourself or find them in the linux code. As I said, the only things needed are:

- definition of size_t
- defition of malloc (probably not a must if you turned off memory leak detection)
- defition of va_list. This might be the most troublesome, I'm not sure if this is supported in kernel development...

Thanks,

Bas

xiaohong liu

unread,
Aug 5, 2011, 3:46:11 AM8/5/11
to cpputest
So glad to see this email:D

I will try to find the header location and include them to try.
> ...
>
> read more »

xiaohong liu

unread,
Aug 7, 2011, 5:44:05 AM8/7/11
to cpputest
Hi, Bas and Terry,

I tried the way to find replace header files in customized linux
library, the result seems when I try to compile cpp test files, I
should not only include all possible path but also take all parameters
used for the production ko. I need more work time for it since I'm not
familiar with it.

So I'd like to try Terry's way, but several points to confirm after
first trial :)
1. it is myTestsInC.c, where I can include other headerfile like
"ont_hal.h" and call other functions to be test.
2. compile myTestsInC.c with -nostdinc, but compile CppWrapperTest.cpp
still with stdinc?
3. I checked CppUTest/TestHarness_c.h, it still include <stddef.h> in
it. There is problem. CppUTest version I used is 2.3
a) if I replace the corresponding head file in customized library,
the compiling of myTestsInc.c -nostdinc will pass, but
CppWrapperTest.cpp will not, because it will finally still cao
TestHarness_c.h
==========make result=========================
compiling AllTests.cpp
In file included from /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
linux-2.6.34.6/include/linux/stddef.h:4,
from /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
linux-2.6.34.6/include/linux/posix_types.h:4,
from /home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/
linux-2.6.34.6/include/linux/types.h:14,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness_c.h:78,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/MemoryLeakWarningPlugin.h:46,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/TestHarness.h:77,
from /home/edgijlq/UnitTestFramework/CppUTest/include/
CppUTest/CommandLineTestRunner.h:31,
from ./AllTests.cpp:28:
/home/edgijlq/T063GMIII_VOBS/ONT_SW_bba/linux-2.6.34.6/include/linux/
compiler.h:30:32: error: ISO C does not permit named variadic macros
================================================
4. With this way, can I still use the functions for code substitution
like UT_PTR_SET?

thanks
Xiaohong Liu

---------------------------------------------------------------------------------------------------
> In CppWrapperTest.cpp
>
> extern "C" {
>         #include "myTestsInC.h"
>
> }
>
> TEST_GROUP(CppWrapperTest)
> {
>
> };
>
> TEST(CppWrapperTest, test_name)
> {
>    test_in_c_with_name(parameters);
>
> }
>
> Then the myTestsInC.h would be:
>
> extern void test_in_c_with_name(parameters);
>
> Then you can have the myTestsInC.c with:
>
> #include "CppUTest/TestHarness_c.h"
>
> void test_in_c_with_name(parameters)
> {
>         // Use the C style macros rather than the C++ style
>
> }
>
> With this, you can compile the myTestsInC.h with the -nostdinc and link it to CppUTest ;)

On Aug 5, 10:03 am, Bas Vodde <b...@odd-e.com> wrote:

Bas Vodde

unread,
Aug 12, 2011, 6:30:45 AM8/12/11
to cppu...@googlegroups.com

Hi,

To keep all up-to-date. This discussion went offline, but I heard that now the first tests are running.

However, its the same method as Terry mentioned. This means we'll probably need to add support for generating that C++ file in the middle to reduce the work effort of this.

Bas

Joshua Shearer

unread,
Mar 24, 2016, 6:34:03 PM3/24/16
to cpputest
Thank you for this post, it has really helped me out alot.  I had to change the formatting a little....just hitting the delete key to change the spacing a little to get it to work....I think just the way it copied over, it really saved me, now I can continue solving other errors in my build.  Here is the slightly edited spacing:


#ifndef
_LINUX_STDDEF_H
 #define _LINUX_STDDEF_H

 #include <linux/compiler.h>

#undef NULL
 #if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void*)0)
#endif

#ifdef __KERNEL__

enum {
        false   = 0,
        true    = 1
};

#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#endif /* __KERNEL__ */

#endif


Thank you again I really appreciate the help.
Reply all
Reply to author
Forward
0 new messages