C preprocessor macros aren't so b-

C preprocessor macros aren't so b-

Other urls found in this thread:

ioccc.org/2015/muth/hint.html
stackoverflow.com/questions/2873850/is-there-an-equivalent-in-c-for-c-templates
twitter.com/SFWRedditVideos

...

OP isn't such a f-

Why the fuck would you do matrix math in macros? Inline function that shit

don't blame bad programming on the language you shit nugget, imagine what kind of scat party this would be if it was written in Haskell

this way the compiler can automatically vectorize it for you

-ad

Seriously though, never use C macros, they bloat up your binary with repeated blocks of code instead of a simple function call which the compiler can inline and optimize away if it's commonly used in your code

oh sweetie
set the right flags (if you need to set any at all) and for loops will perform identically
but you know what, the worst part is that you probably don't even know about SIMD instructions

Use macros only when you write embedded time-critical code

Give me 1 (one) good reason not to do this with C++ templates.

The compiler can optimize macros too.
If the compiler inlines a function it's the same as having a macro. Also, a function that is not inlined causes additional overhead because of the call

>and for loops will perform identically
What kind of overhead is there if we don't set specific flags?

>complains about preprocessor
>shows trivial matrix multiplication

ioccc.org/2015/muth/hint.html

Compilation times

What year is it?

>he doesn't know that Facebook just gave a talk on how templates helped speed up their compilation tikes by as mich as 50%

>2017
>using C
>not using C++

Brainlet.

>2017
>using a shitty 45yo language
>not using SIMD

What languages have proper support for SIMD?

C

>for loops will perform identically
unlikely
>SIMD instructions
no such thing

I can't count on the compiler to perform loop unrolling, it only recognizes very simple, blatant cues that you're writing simd-optimized code, and at that point you might as well start using xmmintrin.h

you have no idea what you're talking about
>it only recognizes very simple, blatant clues
you have no idea what you're talking about

i bet you guys think new is slower than malloc; when did it become okay on this board for people who don't know anything about a topic to comment as if they did?

actually I'm better than you in every way

If you can't implement a language feature without using non-standard compiler-specific hooks, it's shit.

only i can think about it's that's c and not C++

yep
stackoverflow.com/questions/2873850/is-there-an-equivalent-in-c-for-c-templates

>thinks O2 is compiler specific, i.e. has never seen a modern compiler
>doesn't recognize that everyone and their mother uses compiler flags in industry and open source
>thinks writing a lot unsafe, bug-prone code that ultimately has the same performance as something in C++ with a flag is even remotely good practice or worth feeling superior for
C has its places, but not for any of the reasons you've brought up

Performing an operation before compilation is quite different than performing it in a loop, no matter how fast.

better than having no macros at all

if you're saying the preprocessor and the compiler are different things, you'd be correct, but the generated machine code will likely be the same or at least perform the same. additionally, there are a host of reasons to avoid using macros whenever possible.

You're right, but you're a cunt.

GCC "can" generate simd code and it will, it's just bad at it.