Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to compile the example on termux #65

Open
chenyulue opened this issue Sep 27, 2022 · 2 comments
Open

Fail to compile the example on termux #65

chenyulue opened this issue Sep 27, 2022 · 2 comments

Comments

@chenyulue
Copy link

Firstly, thanks for the awesome testing framework.

I've used libcester on termux, but failed to compile the given example. The errors are as follows:

In file included from ./test.c:2:
/data/data/com.termux/files/usr/local/include/exotic/cester.h:283:10: error: field has incomplete type 'FILE' (aka 'struct __sFILE')
    FILE original_stream;                   /**< The actual address of the captured stream. For internal use only.*/
         ^
/data/data/com.termux/files/usr/include/stdio.h:61:8: note: forward declaration of 'struct __sFILE'
struct __sFILE;
       ^
In file included from ./test.c:2:
/data/data/com.termux/files/usr/local/include/exotic/cester.h:407:10: error: field has incomplete type 'FILE' (aka 'struct __sFILE')
    FILE output_stream_address;                         /**< Output stream address. incase the output stream was captured in test it state can be reset. For internal use only. */
         ^
/data/data/com.termux/files/usr/include/stdio.h:61:8: note: forward declaration of 'struct __sFILE'
struct __sFILE;
       ^
In file included from ./././test.c:2:
/data/data/com.termux/files/usr/local/include/exotic/cester.h:3880:13: error: incomplete type 'FILE' (aka 'struct __sFILE') is not assignable
    *stream = *(captured_stream->replaced_stream_handle);
    ~~~~~~~ ^
/data/data/com.termux/files/usr/include/stdio.h:61:8: note: forward declaration of 'struct __sFILE'
struct __sFILE;
       ^
In file included from ./././test.c:2:
/data/data/com.termux/files/usr/local/include/exotic/cester.h:3959:33: error: incomplete type 'FILE' (aka 'struct __sFILE') is not assignable
                        *stream = *(captured_stream->replaced_stream_handle);
                        ~~~~~~~ ^
/data/data/com.termux/files/usr/local/include/exotic/cester.h:367:43: note: expanded from macro 'CESTER_ARRAY_FOREACH'
                                          z\
                                          ^
/data/data/com.termux/files/usr/include/stdio.h:61:8: note: forward declaration of 'struct __sFILE'
struct __sFILE;
       ^
4 errors generated.

My compiler is clang of version 15 on termux. Then I check it on windows with clang of the same version, and no error happens.

Maybe this error is related to the termux platform, but I'm not sure. If you are free, please check it. Thanks!

@Thecarisma
Copy link
Member

Hello, @chenyulue I will try to simulate your environment today to see if I can reproduce the error.
And also I have an update in the pipeline to make the FILE capturing and testing feature optional will merge that to the main branch today.

@chenyulue
Copy link
Author

After some search, I think I've found the reason for the above error.

In the termux, the stdio.h file includes the following snippet:

#if __ANDROID_API__ < 24
#include <bits/struct_file.h>
#endif

The struct_file.h defines the FILE struct. In my phone , __ANDROID_API is 24, so unfortunately in the cester.h header, the FILE is not defined.

So I add the following code into the cester.h header:

#ifdef __ANDROID_API__
#include <bits/struct_file.h>
#endif

After that, at least the given example can be compiled and run successfully. I'm not sure whether there are any other issues. I'll check it in my real projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants