Discover and read the best of Twitter Threads about #DEFINE

Most recents (13)

I have checked in improvements to #VulkanScneneGraph shader composition support so that now a range of shader variants can be pre-compiled to SPIR-V and built as part of the library itself:

github.com/vsg-dev/Vulkan…

This can mean no more loading and compiling shaders at runtime!
Shader composition might at first seem like another layer of complexity on top of GLSL shaders, but it actually makes shader and C++ code management easier once you understand how to use it.

To explain the improvements I've started a thread on vsg-users:
groups.google.com/g/vsg-users/c/…
The #VulkanSceneGraph uses the #pragma(tic) shader composition approach that I developed as part of the #OpenScenegraph project, allow apps to inject #define into shader compilation

This text.vert shader illustrates use of 3 different #defines:
github.com/vsg-dev/vsgExa…
Read 6 tweets
0 で true 系の言語があるのか、マジか。

古の C/C++ 脳だからびっくりした。
一応アレか。

成功(正常)は常に単一の状態しか無いのでゼロ値で、
失敗(異常)は色んな状況が有り得るから非ゼロ、
って言う思想かなぁ?
俺のイメージだとどうしても

#define FALSE 0;

が先行しちゃう。
TRUE 定義に関しては 1 なのか 非0 なのかで派閥あると思うけど。
Read 5 tweets
@Skytrias [1/n] I haven't covered that yet (I will probably do it in the next part), but I control properties like size, colors, fonts, and some other things with stacks. So, for example, you might push a default size for each axis on the stack (as well as a default font, etc.), then...
@Skytrias [2/n] ...if you want to deviate a size, color, font, etc. for a button, you would just push a new value onto the associated stack before the button call, and then pop afterwards.
@Skytrias [3/n] I am really not that big of a "go nuts with C macros" guy, but there's one exception, and that's these widget property stacks. It all comes down to this:

#define DeferLoop(start, end) for(int _i_ = ((start), 0); _i_ == 0; _i_ += 1, (end))
Read 5 tweets
C言語では文字列処理の実装にいちいち個性が出る。これはCという言語の文字列実装が貧弱すぎ(char*としてしか扱えない)、string.hで提供されている標準ライブラリも貧弱すぎるのが悪いと思っている。
まず文字列領域を配列で取るかmallocで取るかで分かれる。その大きさをchar strbuf[256]と直接書くか、#define STRBUF_SIZE 256とかマクロに書くかで分かれる。そのマクロを.cのほうに書くか.hに書くかでまた分かれる。
文字列バッファ長を変える可能性を考えて#ifndef STRBUF_SIZEと囲うか、strbuf_sizeを引数に追加するか。引数の型をintにするかsize_tにするかでまた分かれる。そもそも文字列を扱うのにいちいち最大長を考えなきゃいけないC言語の仕様が悪いんだけど、それを言っても始まらない。
Read 8 tweets
$ du -sh .git
2.6G .git
$ git gc
(currently running, we'll share output when it's done)
this is our local copy of the nixpkgs repo, which we keep on most of our machines because it's handy
Read 157 tweets
#define SYS_objc_bp_assist_cfg_np 535

(From the Xcode RC)
As expected, _objc_init in libobjc now uses this. The system call exists in the A14 kernel but returns KERN_FAILURE. As far as I can tell, the bottom 12 bits are the offset to the branch, the next five bits the register the selector is in, and then another five for the class. Ghidra decompilation snippe...
(No idea what the top bit is?)
Read 3 tweets
Do you know about it?

C++ tips and tricks for Competitive Programming |
🧵👇
1⃣ Use <bits/stdc++.h> Header File

<bits/stdc++.h> is a most commonly and widely used header file in competitive programming world.

It is a header file that includes all the standard libraries.
2⃣ “\n” versus endl

Both sound the same right but endl takes more execution time than “\n”

Here is the reason: 👇

"\n": it inserts a new line.
"endl": it inserts a new line and flushes the stream.

TIP:
Hence to avoid this mistake we can use define a macro:
#define endl "\n"
Read 3 tweets
Exploitable heap overflow in libgcrypt 1.9.0 (┛ಠ_ಠ)┛彡┻━┻

It's the crypto library that gpg uses. Homebrew has 1.9.0 right now. 🚨

dev.gnupg.org/T5259
It's in cipher/hash-common.c (!) and looks like it's hit when extra data is hashes after finalizing the hash.

Doing that is a partial mitigation for timing side channels on the length of a hashed message. Very partial.

dev.gnupg.org/rC512c0c752769…
Reported-by: Tavis Ormandy <taviso@gmail.com>

👋 @taviso
Read 19 tweets
#102 The result of an infinite recursion in template instantiation is undefined behavior: eel.is/c++draft/temp.…

godbolt: godbolt.org/z/jh6bsr Image
#103 Referring to any non-static member or base class of an object in the handler for a function-try-block of a
constructor or destructor for that object results in undefined behavior: eel.is/c++draft/excep…

godbolt: godbolt.org/z/6Yzvvc Image
#104 If the token defined is generated as a result of this replacement process or use of
the defined unary operator does not match one of the two specified forms prior to macro replacement, the
behavior is undefined: eel.is/c++draft/cpp.c…

godbolt: godbolt.org/z/xrdfT4 ImageImage
Read 20 tweets
1/ @werat asked about whether the debugger was using the C# compiler or language service in VS 2002. It was not. The debugger has a component called an ‘expression evaluator’ that is provided per language and is responsible for parsing and evaluating expressions when stopped at a
2/ breakpoint. For example, if you type into the immediate window, hover over a variable, type into the watch window, etc. the expression evaluator is involved. The debugger and the language service are actually deeply integrated in a number of scenarios in VS, which may
3/ initially seem surprising. I may talk about more of these scenarios in the future, but to give a flavor, when you set a breakpoint at design time the language service is involved, when you are using Edit and Continue the LS is involved, the range of what is being evaluated
Read 14 tweets
I thought I’d do some real code review for the @Imperial_JIDEA CovIdSim, rather than the nonsense political one published. Not exhaustive, but hopeful constructive. /1
So the first thing I noticed when trying to get it going is that scanning the population file takes a long time: 77.96 seconds in this run. /2
And further research showed that just measuring the file was taking 14.4 seconds. It’s a big file, but that’s longer than it should be, so what is going wrong? /3
Read 28 tweets
For 2020 I'm doing a 1 C++ Best Practice per retweet thread!

I wrote my first blog article about C++ best practices in 2007. In many ways I've been repeating myself over and over again for the last 13ish years.

And very little of what I say is novel.

Thread follows:
Even though I've been repeating many of the same best practices for a while, I think my style is relatively unique.

One client told me "I like how you don't just give us a rule, you tell us why. <other guy> never gives us reasons."
My goal as a trainer and a contractor (seems to be) to work myself out of a job.

I want everyone to:

1. Learn how to experiment for themselves
2. Not just believe me, but test it
3. Learn how the language works
4. Stop making the same mistakes of the last generation
Read 63 tweets
Let’s do this:

One Like, One Undefined Behavior.

I plan on running this through the weekend at least.

#Cplusplus
#Programming
Signed integer overflow/underflow is undefined behavior

int x1=std::numeric_limits<int>::max()+1;
int x2=std::numeric_limits<int>::min()-1;

[expr.pre]p4 eel.is/c++draft/expr#…

godbolt: godbolt.org/z/Ga-fbb
#2 Signed integer overflow/underflow is undefined behavior 2

int x3=std::numeric_limits<int>::min() / -1;

[expr.pre]p4 eel.is/c++draft/expr#…

godbolt: godbolt.org/z/ytC8oi
Read 65 tweets

Related hashtags

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!