/dpt/ - Daily Programming Thread

Previous: What are you working on, Any Forums?

Attached: 1548563327292.png (615x782, 25.46K)

Lua is a table oriented programming language

I'm converting some 15 year old project from whatever build system they used to use to cmake. I have about 100 .cpp files, is there any way to add them all the the add_executable(...) portion of my cmake without having to enter the name of every single file? For the headers I merely had to set the include directory and it sees them all, how can I do that for src files as well?

echo *.cpp >> cmakefile

So I decided to dabble into Golang, and I noticed their error exception handling only returns strings? Is that right or can it return other types?

Also if I happen to have multiple parts of my code being able to get handled by the same error exception, idk if thats a thing I am still new to this language, would it be better just to create a function instead of handling same error exception in different parts of my code?

Attached: errorcheckgolang.png (299x270, 6.56K)

i am making a single linked list, so i have a list node to keep track of the top of the list.

i dont want to make a pointer to the list, i want to pass the list directly to the function

can i use casting or something so it doesnt complain about the type difference? it seems kinda clumsy to have create a pointer to the list just so it can be passed as a double pointer to the function.

int main(void)
{
Node list = {0};
//Node* listPtr = &list;
...
addNode(&list, value); //&listPtr
}
void addNode(Node** list, int value)
{
Node* newNode = malloc(...)
...
*list = newNode;
}

Attached: 381741234.png (302x405, 190.48K)

I mean yeah, but surely there is some built in way to do this instead of having to paste in 100 file names? Like I know you can GLOB which works, but the cmake devs have this to say on the matter
>We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.

Error is an interface, it nas the Error method that returns an error message.
The simplest errors are just that, but you can extend that interface and include other information about the error if necessary for handling it.

the point of the double pointer is that you can avoid having a dummy node just to hold the pointer to the head of the list.
Node* list = NULL;
addNode(&list, value);

>i dont want to make a pointer to the list,
> it seems kinda clumsy to have create a pointer to the list just so it can be passed as a double pointer to the function.
That's normal and the way you're supposed to do it.

>having to paste in 100 file names
user even in fucking Notepad this is just Ctrl+A Ctrl+C Ctrl+V.

oh right, i had that confused, ty

say for whatever reason or for some other scenario, could i do something like this
addNode((Node*)&list, val);

and have the function properly work as if i had passed it &listPtr? i've never really used casting before

the point isn't so much on how easy it is to do, but rather is there a more proper way to do it that doesn't involve adding a hundred lines of files to my CMakeLists

No, dereferencing a pointer of the wrong type will result in misinterpreting the data there.

Your root node should probably be dynamically allocated too btw.

I think I've just thought too much and tied myself into a mental knot.
we have matrices consisting of 0s and 1s. we want to select a subset of rows such that we have exactly one 1 in each column. we use knuths algorithm x, pic related.

we have the matrix
01110
11011
10001
clearly here the solution consists of the first and the third rows. let's say we pick the first column as c. then we go down to the second row where we have a 1 and we have to delete all the cols were we have a 1 in the second column and all the rows where there is a 1 in a column where row 2 has a 1. so we delete the whole matrix and recurse into the algorithm anew with an empty matrix. therefore success and we end up with the solution being to pick row 2. this is wrong.

what should have happened is after our picking row 2 we delete and end up with a non-empty matrix that we recurse into the algorithm with. here we cannot find any 1s in the first column and so we terminate unsuccessfully and move up a level of recursion. then we pick row 3 in our solution instead of row 2 and this leads to our further picking row 1 and then recursing with an empty matrix, success. solution is 1, 3.

Attached: knuth_algx.png (1340x900, 160.5K)

Which one do you think is easier to think about: Variables inside an object, or all objects referencing to some global / shared datastructure where you store the same information?

I think it would work if you can have a 0xN matrix, ie no more rows but still columns, since you wouldn't delete the middle column.

No. Also as the documentation says globbing is a shitty practice. One thing you could do is compartmentalize the existing files logically into more targets, so instead of a single executable with 100 source files, you have x targets each with a more manageable amount of source files. Either way, I don't get what the problem is with telling the tool that builds your code what code you want to it build.

ty user

Anyone ever used Rhapsody before? Trying to figure out how to generate without the framework...

The shapes that my furry GAN is generating are starting to become recognizable.

Attached: 31.jpg (2066x2066, 638.54K)

>the generated build system cannot know when to ask CMake to regenerate
Just goes to show how half-assed cmake is.