envelope-project / laik

Other
9 stars 8 forks source link

Example from README does not compile #170

Closed jounathaen closed 5 years ago

jounathaen commented 5 years ago

I tried to compile the example from the README, but it did not compile, neither with gcc nor with clang. Output:

> clang -llaik main.c -o simple
main.c:11:37: warning: incompatible pointer types passing
      'Laik_Group *' (aka 'struct _Laik_Group *') to parameter of type
      'Laik_Instance *' (aka 'struct _Laik_Instance *')
      [-Wincompatible-pointer-types]
    Laik_Data* a = laik_new_data_1d(world, laik_Double, 1000000);
                                    ^~~~~
/home/xxx/.local/include/laik/data.h:76:44: note: passing argument to
      parameter 'i' here
Laik_Data* laik_new_data_1d(Laik_Instance* i, Laik_Type* t, int...
                                           ^

main.c:13:74: error: too few arguments to function call, expected 5,
      have 4
    laik_switchto_new_partitioning(a, laik_new_block_partitioner1(), 0, 0);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                       ^
/home/xxx/.local/include/laik/data.h:146:1: note: 
      'laik_switchto_new_partitioning' declared here
Laik_Partitioning* laik_switchto_new_partitioning(Laik_Data*, L...
^

main.c:27:39: warning: incompatible pointer types passing
      'Laik_Group *' (aka 'struct _Laik_Group *') to parameter of type
      'Laik_Instance *' (aka 'struct _Laik_Instance *')
      [-Wincompatible-pointer-types]
    Laik_Data* sum = laik_new_data_1d(world, laik_Double, 1);
                                      ^~~~~
/home/xxx/.local/include/laik/data.h:76:44: note: passing argument to
      parameter 'i' here
Laik_Data* laik_new_data_1d(Laik_Instance* i, Laik_Type* t, int...
                                           ^

main.c:28:66: error: too few arguments to function call, expected 5,
      have 4
    laik_switchto_new_partitioning(sum, laik_All, LAIK_DF_None, 0);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                               ^
/home/xxx/.local/include/laik/data.h:146:1: note: 
      'laik_switchto_new_partitioning' declared here
Laik_Partitioning* laik_switchto_new_partitioning(Laik_Data*, L...
^

main.c:34:42: error: too few arguments to function call, expected 5,
      have 4
            LAIK_DF_Preserve, LAIK_RO_Sum);
                                         ^
/home/xxx/.local/include/laik/data.h:146:1: note: 
      'laik_switchto_new_partitioning' declared here
Laik_Partitioning* laik_switchto_new_partitioning(Laik_Data*, L...
^
2 warnings and 3 errors generated.
weidendo commented 5 years ago

At the moment, there is no mechanism in place to ensure that the README example works, and it will break if it is not updated on API changes, which still happen in relatively high frequency. There are unfinished parts (like data layout declaration) and an API cleanup required before fixing as version 1.0.

It would be good to have a test case which automatically gets embedded into the README (probably needs the README to be generated from a template). I will keep this issue open as reminder.

This said, the example/ subdirectory has code which is used in the test suite, and always will work.

weidendo commented 5 years ago

... have a test case which automatically gets embedded into the README

Fixed in 1fd76baf3