Day 48 — Curlyboi walks into the Cheese Shop
17 October 2020 · recurse-center TweetI made Linux and MacOS wheels for curlyboi
and uploaded them to PyPI! You can now install curlyboi using:
$ pip install curlyboi
Since I used pybind11
(which works with C++ code) to wrap curlyboi
, I had to rename all the .c
files to .cpp
.
I ran into an error when I did that:
lib/backend.cpp: In function ‘Point* create_cell(int, int, wchar_t*)’:
lib/backend.cpp:122:25: error: invalid conversion from ‘void*’ to ‘Point*’ [-fpermissive]
122 | Point* cell = malloc(sizeof(*cell));
| ~~~~~~^~~~~~~~~~~~~~~
| |
| void*
lib/backend.cpp: In function ‘Board* create_board(Point*, Point*, int, int)’:
lib/backend.cpp:147:26: error: invalid conversion from ‘void*’ to ‘Board*’ [-fpermissive]
147 | Board* board = malloc(sizeof(*board));
| ~~~~~~^~~~~~~~~~~~~~~~
| |
| void*
Turns out that in C++, malloc(sizeof(*cell))
is not valid and we have to explicitly specify the type of pointer returned by malloc
by putting a (struct Point *)
in front of it!