watery01 / libyuv

Automatically exported from code.google.com/p/libyuv
0 stars 0 forks source link

public API headers should be C-compatibile #207

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a C source file.
2. include libyuv.h
3. have it compile and link

What is the expected output? What do you see instead?
Build errors relating to types, C++ style casts.

What version of the product are you using? On what operating system?
r613

Please provide any additional information below.

mjpeg_decoder.h is probably a non-starter (maybe ifdef around it?), but the 
attached should clear up most of the other issues.

scale.h's bool typedef is probably questionable, it might be enough to ifdef 
around the deprecated api.

Original issue reported on code.google.com by jz...@google.com on 22 Mar 2013 at 1:05

Attachments:

GoogleCodeExporter commented 9 years ago
Changes look okay, but I think you can just refer to the enum name once.

The intent is you need a C++ compiler to build the library (although most of it 
is C99), but a C program could link it in.

I've made a small cpuid.c file to test it and see quite a few build errors
d:\src\libyuv3\trunk>call python build\gyp_chromium -fninja -G 
msvs_version=2012 --depth=. libyuv_test.gyp
Updating projects from gyp files...
ninja: Entering directory `out\Release'
[15/19] CC obj\util\cpuid.cpuid.obj
FAILED: ninja -t msvc -o obj\util\cpuid.cpuid.obj -e environment.x86 -- cl.exe 
/nologo /showIncludes /FC @obj\util\cpuid.cpuid.obj.r
sp /c ..\..\util\cpuid.c /Foobj\util\cpuid.cpuid.obj /Fdobj\cpuid.pdb
d:\src\libyuv3\trunk\include\libyuv\rotate.h(42) : error C2146: syntax error : 
missing ')' before identifier 'mode'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(42) : error C2081: 'RotationMode' 
: name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\rotate.h(42) : error C2061: syntax error : 
identifier 'mode'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(42) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(42) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(51) : error C2146: syntax error : 
missing ')' before identifier 'mode'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(51) : error C2081: 'RotationMode' 
: name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\rotate.h(51) : error C2061: syntax error : 
identifier 'mode'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(51) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\rotate.h(51) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(217) : error C2146: syntax 
error : missing ')' before identifier 'rotation'
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(217) : error C2081: 
'RotationMode' : name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(217) : error C2061: syntax 
error : identifier 'rotation'
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(217) : error C2059: syntax 
error : ';'
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(217) : error C2059: syntax 
error : ','
d:\src\libyuv3\trunk\include\libyuv\convert_argb.h(218) : error C2059: syntax 
error : ')'
d:\src\libyuv3\trunk\include\libyuv\convert.h(246) : error C2146: syntax error 
: missing ')' before identifier 'rotation'
d:\src\libyuv3\trunk\include\libyuv\convert.h(246) : error C2081: 
'RotationMode' : name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\convert.h(246) : error C2061: syntax error 
: identifier 'rotation'
d:\src\libyuv3\trunk\include\libyuv\convert.h(246) : error C2059: syntax error 
: ';'
d:\src\libyuv3\trunk\include\libyuv\convert.h(246) : error C2059: syntax error 
: ','
d:\src\libyuv3\trunk\include\libyuv\convert.h(247) : error C2059: syntax error 
: ')'
d:\src\libyuv3\trunk\include\libyuv\mjpeg_decoder.h(22) : error C2061: syntax 
error : identifier 'libyuv'
d:\src\libyuv3\trunk\include\libyuv\mjpeg_decoder.h(22) : error C2059: syntax 
error : ';'
d:\src\libyuv3\trunk\include\libyuv\mjpeg_decoder.h(22) : error C2449: found 
'{' at file scope (missing function header?)
d:\src\libyuv3\trunk\include\libyuv\mjpeg_decoder.h(186) : error C2059: syntax 
error : '}'
d:\src\libyuv3\trunk\include\libyuv\scale.h(34) : error C2146: syntax error : 
missing ')' before identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale.h(34) : error C2081: 'FilterMode' : 
name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\scale.h(34) : error C2061: syntax error : 
identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale.h(34) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\scale.h(34) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\scale.h(55) : error C2146: syntax error : 
missing ')' before identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale.h(55) : error C2081: 'FilterMode' : 
name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\scale.h(55) : error C2061: syntax error : 
identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale.h(55) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\scale.h(55) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\scale.h(65) : error C2146: syntax error : 
missing ')' before identifier 'interpolate'
d:\src\libyuv3\trunk\include\libyuv\scale.h(65) : error C2081: 'bool' : name in 
formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\scale.h(65) : error C2061: syntax error : 
identifier 'interpolate'
d:\src\libyuv3\trunk\include\libyuv\scale.h(65) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\scale.h(65) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\scale.h(71) : error C2146: syntax error : 
missing ')' before identifier 'interpolate'
d:\src\libyuv3\trunk\include\libyuv\scale.h(71) : error C2081: 'bool' : name in 
formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\scale.h(71) : error C2061: syntax error : 
identifier 'interpolate'
d:\src\libyuv3\trunk\include\libyuv\scale.h(71) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\scale.h(71) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\scale.h(75) : error C2146: syntax error : 
missing ')' before identifier 'use'
d:\src\libyuv3\trunk\include\libyuv\scale.h(75) : error C2061: syntax error : 
identifier 'use'
d:\src\libyuv3\trunk\include\libyuv\scale.h(75) : error C2059: syntax error : 
';'
d:\src\libyuv3\trunk\include\libyuv\scale.h(75) : error C2059: syntax error : 
')'
d:\src\libyuv3\trunk\include\libyuv\scale_argb.h(27) : error C2146: syntax 
error : missing ')' before identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale_argb.h(27) : error C2081: 
'FilterMode' : name in formal parameter list illegal
d:\src\libyuv3\trunk\include\libyuv\scale_argb.h(27) : error C2061: syntax 
error : identifier 'filtering'
d:\src\libyuv3\trunk\include\libyuv\scale_argb.h(27) : error C2059: syntax 
error : ';'
d:\src\libyuv3\trunk\include\libyuv\scale_argb.h(27) : error C2059: syntax 
error : ')'
        d:\src\libyuv3\trunk\include\libyuv\basic_types.h(58) : see declaration of 'uint32'
        d:\src\libyuv3\trunk\include\libyuv\basic_types.h(58) : see declaration of 'uint32'
        d:\src\libyuv3\trunk\include\libyuv\basic_types.h(58) : see declaration of 'uint32'
        d:\src\libyuv3\trunk\include\libyuv\basic_types.h(58) : see declaration of 'uint32'
d:\src\libyuv3\trunk\include\libyuv\video_common.h(47) : error C2056: illegal 
expression
d:\src\libyuv3\trunk\include\libyuv\video_common.h(48) : error C2065: 
'static_cast' : undeclared identifier
d:\src\libyuv3\trunk\include\libyuv\video_common.h(48) : error C2275: 'uint32' 
: illegal use of this type as an expression

Original comment by fbarch...@chromium.org on 22 Mar 2013 at 7:14

GoogleCodeExporter commented 9 years ago
Attached removes the enum name and protects mjpeg_decoder.h.
I can now include libyuv.h in a test C file. The linkage in libyuv.a looks 
right, so it should work.

Original comment by jz...@google.com on 22 Mar 2013 at 7:26

Attachments:

GoogleCodeExporter commented 9 years ago
fixed in r617

Original comment by fbarch...@chromium.org on 22 Mar 2013 at 8:42