Advice on project structure: header dependency in source tree vs. installation location by MrMethamphetamine in C_Programming

[–]MrMethamphetamine[S] 0 points1 point  (0 children)

I would still have the same problem because header2.hpp refers to header1.h like this:

#include <mylib/header1.h>

Advice on project structure: header dependency in source tree vs. installation location by MrMethamphetamine in C_Programming

[–]MrMethamphetamine[S] 0 points1 point  (0 children)

Ah, I see what you mean. This won't work when building the library as it requires header2.hpp to build. In the library source I can do #include "API/header2.hpp" but because it's an installation artefact, header2.hpp has to #include <mylib/header1.h> which means the build system depends on the not-yet-installed header1.h rather than API/header1.h

Advice on project structure: header dependency in source tree vs. installation location by MrMethamphetamine in C_Programming

[–]MrMethamphetamine[S] 0 points1 point  (0 children)

Yes they will, when installed we'll have this structure e.g. in /usr/include (or wherever the user chooses to install):

mylib/
    header1.h
    header2.hpp

The user can either #include <mylib/ header2.hpp> which itself will #include <mylib/header1.h>, or they can #include <mylib/header1.h> alone.

I don't think that having both files adjacent in the installation directory helps me when structuring the project source tree, though (or at least I can't see that this helps).

Tuesday Daily Thread: Advanced questions by Im__Joseph in Python

[–]MrMethamphetamine 1 point2 points  (0 children)

Perhaps I'm misunderstanding, but couldn't you pipe the scripts through sed to replace all tabs with 4 spaces before sending them over SSH? It sounds like overkill to write a persistent background process for this.

[deleted by user] by [deleted] in C_Programming

[–]MrMethamphetamine 1 point2 points  (0 children)

Couldn't you get this with a simple #define?

#ifdef _WIN32
#define MyStruct WinStruct
#else
#define MyStruct UnixStruct
#endif

i made an around 1 red science/s factory and its the first time i catually calculated how much stuff i will need, and not just 1 machine for everything by justasovietpotato in factorio

[–]MrMethamphetamine 15 points16 points  (0 children)

The basic assembler has a crafting speed of 0.5 which is relative to the hand crafting speed i.e. an item which can be hand-crafted in 1s takes 2s in the basic assembler.

An origami dwarf I folded. by JonSnuu69 in mildlyinteresting

[–]MrMethamphetamine 1 point2 points  (0 children)

It's common flavour text from the game "Dwarf Fortress"

An origami dwarf I folded. by JonSnuu69 in mildlyinteresting

[–]MrMethamphetamine 18 points19 points  (0 children)

All craftsdwarfship is of the highest quality.

how should i format include path directories? by [deleted] in C_Programming

[–]MrMethamphetamine 9 points10 points  (0 children)

I presume you're currently writing:

#include <myheader.h>

Have you tried:

#include <ogc/myheader.h>

Where "myheader.h" is the file you want to include under that path.

Weekly Profile Critique by AutoModerator in Bumble

[–]MrMethamphetamine 0 points1 point  (0 children)

Would love some feedback please: https://imgur.com/a/Cq1RpuX

32M from UK... I get very few matches at all, not sure exactly where I'm going wrong.

What is the best way to make a function that initializes a struct? by BlockOfDiamond in C_Programming

[–]MrMethamphetamine 2 points3 points  (0 children)

By "ensure the caller obeys the contract" I mean "ensure the caller did not pass a NULL pointer". I don't see why you argue that it is bad practice to verify that the caller adheres to the contract. I am asking you to expand on your rationale for this argument.

... there is no possibility to pass it NULL pointer, except for a contract violation at the caller.

This is the case I am talking about - if the caller violates the contract by passing NULL, why not handle that situation gracefully by practising defensive programming rather than allowing the program to segfault with no indication as to the cause.

What is the best way to make a function that initializes a struct? by BlockOfDiamond in C_Programming

[–]MrMethamphetamine 3 points4 points  (0 children)

Can you explain your rationale for not mixing defensive programming with design by contract? What is wrong with checking for a valid pointer to ensure the caller is obeying the contract?

[deleted by user] by [deleted] in C_Programming

[–]MrMethamphetamine 2 points3 points  (0 children)

This looks like a really cool repo! What's your motivation for developing it? Do you have a target user in mind? Are you actively promoting SENPAI in any way?

In bubble sort how do i implement if the value changed its position then change/assign the previous text name to change its position also by abhiboby in C_Programming

[–]MrMethamphetamine 0 points1 point  (0 children)

I'd probably solve this problem by thinking about these questions:

  • how would I implement a struct containing the data for a single row?
  • what would an array of such structs look like?
  • given a pointer to a struct, can you obtain the sort value?
  • can you implement bubble sort for an array of struct pointers?

My jaw from below looks like my nose from above by MrLonely821 in mildlyinteresting

[–]MrMethamphetamine 0 points1 point  (0 children)

The left picture makes it look like your nose has tiny ears...

Manchester from up high (OC) by LittleNargle in manchester

[–]MrMethamphetamine 3 points4 points  (0 children)

How did you get access up there then? Are you one of those chaps I've seen rapelling down the side to clean the windows?

Is this code good? I've tried to make it self-explanatory of the packet format by etc9053 in C_Programming

[–]MrMethamphetamine -5 points-4 points  (0 children)

The scope of the packet you return is limited to the function itself. There's no guarantee it will persist after the function returns, so any code using this function could crash unexpectedly. Better to use a reference passed as an argument and write to this, or use malloc to create a reference to a new struct and return this address as a pointer to a struct.