Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
qsvui
Aug 23, 2003
some crazy thing

what does this mean

Hughmoris posted:

Do modern C books, tutorials etc... promote safe C coding or is it really that easy to shoot yourself in the foot?

Short answer, yes. I guess with the addition of all the bounds-checked functions that they added in C11 (such as gets_s), you could argue that "modern C" is trying to be more safe. But C still lets you do a lot of crazy things that you shouldn't do and that you didn't intend to do.

Also, I don't think anyone uses all those functions that end in _s.

Adbot
ADBOT LOVES YOU

qsvui
Aug 23, 2003
some crazy thing

Dren posted:

Speaking of CMake do I need to buy their book if I really want to get what the hell is going on? The online references are ok but they tell you nothing of best practices.

Build tools always suck. If your build is a sinking boat and build tools are buckets, the very best buckets have a hole in them jussst small enough that you can bail as fast as you take on water.

You can try googling "Modern CMake" for best practices.

Here was the top result: https://cliutils.gitlab.io/modern-cmake/

Looks to be decent.

qsvui
Aug 23, 2003
some crazy thing

Khorne posted:

but most people don't know cmake well enough to do that so they just say "gently caress cmake it's awful"

tbf even people who know cmake say this

qsvui
Aug 23, 2003
some crazy thing
This book might be worth checking out: https://www.elsevier.com/books/msp430-microcontroller-basics/davies/978-0-7506-8276-3

As for the watchdog timer, some microcontrollers have it on by default and others don't. The MSP430 has it on by default so unless you disable it or reset the timer periodically, your system will reset after the limit has been reached.

qsvui
Aug 23, 2003
some crazy thing

Dawncloack posted:

code:
typedef struct SoundStateKeeper
    {
        unsigned int8_t *currentState; //All of the structs will have this pointer point at the State variable
        unsigned int32_t thisStateValue; //Initialized to zero, used in the first three states
        int32_t (*current_state_func)(* void); 
        void (*state_change)(int32_t); // Only this function can touch State

    }SoundStateKeeper;

This doesn't compile. If you really mean unsigned int8_t, then just write uint8_t. Same goes for the int32_t. For current_state_func, if that isn't taking any arguments, leave out the * next to void.

Dawncloack posted:

- Should I use the restrict or register keywords on the members of the array ? I think restrict on function pointers doesn't work, but I am a beginner.
I wouldn't bother with register. Yes, restrict doesn't work with function pointers.

Dawncloack posted:

- Is it ok to try and bind an inbuilt function into a function pointer like so ?
code:
SoundStateKeeper[CLEANUP_AND_EXIT]->state_change() = exit(int32_t);
It is, but as written, this line doesn't compile. It's already been pointed out, but skip the parentheses on state_change and leave out the argument on exit.

qsvui
Aug 23, 2003
some crazy thing
Powershell thread is here: https://forums.somethingawful.com/showthread.php?threadid=3286440

qsvui
Aug 23, 2003
some crazy thing

lifg posted:

I learned Vi because one job I worked at gave me an option between Emacs and Vi. I think I flipped a coin.

lol why should they have even cared? do you just get fired if you don't pick either?

qsvui
Aug 23, 2003
some crazy thing

Dominoes posted:

You also have sections of C coding, like embedded, that are tied to IDEs to make the toolchains more manageable, or provide low-level visual aids for pins, memory etc. That seems like an odd conflation to me, eg of language editor and hardware aid.

Notepad++ is a step up from "embedded" IDEs as far as text editing goes. I've tried Keil, IAR, and multiple Eclipse knockoffs and they're all uniformly awful.

qsvui
Aug 23, 2003
some crazy thing

you're right, that wasn't very helpful

qsvui
Aug 23, 2003
some crazy thing

Dominoes posted:

The Witness is my fav single-player game, so Jai's got to be good, right?

:thunk:

qsvui
Aug 23, 2003
some crazy thing

ultrafilter posted:

From the terminal explorer.exe $dirname will do what you want. I assume there's nothing weird about invoking it programmatically but Windows so who knows?

There shouldn't be, this exact usage is mentioned in the WSL docs: https://docs.microsoft.com/en-us/windows/wsl/setup/environment#file-storage

qsvui
Aug 23, 2003
some crazy thing
I personally read books and watch conference talks. The talks give a sense of what the current practice is and where things are headed, but the books make better reference material than any video. Paid books tend to be higher quality than free ones and random blog posts, but of course there are exceptions.

qsvui
Aug 23, 2003
some crazy thing

bigperm posted:

At some point it seems like all I can think of is a O(n^2) solution and then I look and someone did it all in one line of bash and I feel like an idiot and that's when I usually give up.

me when doing leetcodes

qsvui
Aug 23, 2003
some crazy thing
I thought the C++ extension for VSCode actually uses Intellisense and not LSP? At least that's how I remember it being marketed as.

Also, why would you need to exit in order to test? Just create a new terminal tab.

qsvui
Aug 23, 2003
some crazy thing
I used your last command with the code snippet and it worked fine for me. Which version of vim are you using?

Adbot
ADBOT LOVES YOU

qsvui
Aug 23, 2003
some crazy thing

Ranzear posted:

Like, what is the double slash divide? Is that actually a thing or just an extraneous escape character being glossed over by everyone?

If the code is Python, that should be a flooring divide as normal Python 3 division is always in floating point.

e: beaten

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply