If I define the function in the main, everything works fine. But if I define the function in another c file, this weir float multiplication problem happens: it gives 0 always.
example1/main.c:
int multiply_by_2(float scalar) {
printf("result: %f\n", scalar*2);
}
int main()
{
multiply_by_2(3);
}
example1/CMakeLists.txt
cmake_minimum_required(VERSION 2.6.0)
project(example C)
add_executable(example main.c)
Output:
result: 6.000000
example2/main.c:
int main()
{
multiply_by_2(3);
}
example2/a.c:
int multiply_by_2(float scalar) {
printf("result: %f\n", scalar*2);
}
example2/CMakeLists.txt:
cmake_minimum_required(VERSION 2.6.0)
project(example C)
add_executable(example main.c a.c)
Output:
result: 0.000000