yyang42 / moulitest

This repository contains tests for several projects done at 42.
127 stars 37 forks source link

make libft_part1: error: ‘memset’ used with constant zero length parameter #14

Closed thomas-touhey closed 9 years ago

thomas-touhey commented 9 years ago

Hi, I wanted to test my libft, but it looks like one of the memset tests won't compile :

In file included from ./project.h:16:0,
                 from tests/00_part1_ft_memset.spec.c:1:
tests/00_part1_ft_memset.spec.c: In function ‘unittest1’:
tests/00_part1_ft_memset.spec.c:9:12: error: ‘memset’ used with constant zero length parameter; this could be due to transposed parameters [-Werror=memset-transposed-args]
  mt_assert(memset(b1, 99, 0) == ft_memset(b1, 99, 0));
            ^

As a workaround, I commented line 9 of the libft_tests/tests/00_part1_ft_memset.spec.c, but why is this error here ?

yyang42 commented 9 years ago

It seems that your compiler is more strict and does not accept a memset() call with zero length. You should use the same error flags as those used at 42 to avoid surprises :)

thomas-touhey commented 9 years ago

I do use the same error flags as the ones I was using at 42 in my Makefile ("clang -Wall -Werror -Wextra", exactly what the moulinette was using according to the traces), and I left your Makefiles as is. But as I'm working on my own computer and as it's not a Macbook... well, I realized today that the differences could be significant. So the errors must come from the builds differences between my gcc/clang and the one at 42. Sorry about taking all that time to realize D:

JulienBalestra commented 9 years ago

The differences are not so bad and they are making you a better programmer.

Between Linux and Darwin kernels you can find some differencies like with is_something series. I use a personnal way like telling to the Makefile which source use to compile : Darwin/Linux under the libft -> https://github.com/JulienBalestra/libft/tree/master/srcs

You also can use define (way I choose for libftASM).

Also, I suggest you to work under Valgrind as soon as possible. In fact Linux (ubuntu / Debian) are more soft with invalid write / read, double free, ... than MacOS (Darwin) is. You can have a program working (and silent real problems) but they wouldn't work under Darwin.

In last, I really abuse of Travis because I don't want to buy an expensive Apple computer just to run test. Get an look how to do here : https://github.com/JulienBalestra/minishell/blob/master/.travis.yml

2015-11-11 18:18 GMT+01:00 Thomas Touhey notifications@github.com:

I do use the same error flags as the ones I was using at 42 in my Makefile ("clang -Wall -Werror -Wextra", exactly what the moulinette was using according to the traces), and I left your Makefiles as is. But as I'm working on my own computer and as it's not a Macbook... well, I realized today that the differences could be significant. So the errors must come from the builds differences between my gcc/clang and the one at 42. Sorry about taking all that time to realize D:

— Reply to this email directly or view it on GitHub https://github.com/yyang42/moulitest/issues/14#issuecomment-155851118.

thomas-touhey commented 8 years ago

I like the way you differenciate the two kernels. I thought about doing it with macros (#ifdef linux), but as the Norm says so, "Macros defining code are forbidden", so I did it the same way as you in the end.

Also, Valgrind and Travis look interesting. I'll try those as soon as I can, thanks. ^^