Earlier quoted context omitted.
> You can just hover over the keyword with an IDE and instantly see that it's just a typedef for static Assuming you're browsing in an IDE, and that the IDE understands your build system. Github for example doesn't detect that it's a typedef for static. There's also the fact that the keyword `internal` is overloaded, and not in a standard way. For example, does it mean that it's not exported (a la dllexport in msvc).…
Internal define for static is actually really good, maybe different keyword like 'fn' would be better cause it doesn't clash with windows.h but, redefining static to a different keyword allows you to search for it in a codebase while static can be a local variable, global variable, function.
4coder editor is now fully open source
91–100 of 108 posts
Re: 4coder editor is now fully open source
#92Earlier quoted context omitted.
Internal define for static is actually really good, maybe different keyword like 'fn' would be better cause it doesn't clash with windows.h but, redefining static to a different keyword allows you to search for it in a codebase while static can be a local variable, global variable, function.
I fundamentally disagree. The reason programming languages work are because things are consistent, if everyone defined their own flavor of keywords then you're not using the same language anymore. On any project I've worked on I would fail a code review for attempting to introduce something like this.
It's great that you would fail a code review in your company for that but it's not relevent.
Re: 4coder editor is now fully open source
#93Earlier quoted context omitted.
It’s perfectly legitimate to say “run the script from a shell where the environment is set up”. In fact, it’s preferable, and you should only attempt to be “smart” and search for that type of thing if you really need it — why use any search logic at all, if it can be avoided. vcvars and its modern incarnations exist to facilitate this. I had already skimmed the cpp (at least the `build` functions). It’s not necessary…
> you should only attempt to be “smart” and search for that type of thing if you really need it — why use any search logic at all, if it can be avoided. vcvars and its modern incarnations exist to facilitate this. But that's the standard for how to do things on Windows. That's how it works. Sure you might not like it, but personally I don't like the implicit assumption that everything is configured and "there" that y…
Here’s part of the powershell version of a build script I have used, where I had fewer build variants, so I didn’t even bother to make a `build` function, I just copy paste the `out=... ; if { ... }` block and change the value of `$out` and which compiler and options are called. Note that you can accomplish this with far fewer variables if you don’t want quite as many build variants as this script supports — it was written as an illustration of how flexible you can make things, rather than how simple things can be, so it supports clang, clang-cl, cl, zig cc, with variants for asan, freestanding, for architectures x86, x64, aarch64:
$ml = @("-nologo","-c","-Zd","-WX","-W3")
...
$clstd = @("-volatile:iso","-permissive-")
$clangcl = @("-nologo","-diagnostics:column","-Z7","-Zo","-FC") + $clstd
$cl = $clangcl + @("-WL","-Gm-","-utf-8")
# -Wall > -W4 but includes very silly things like "function not inlined" for snprintf
$clwx = @("-WX","-W4","-wd4100","-wd4127")
...
$clfree = @("-D","EXAMPLE_FREESTANDING","-Zl","-GS-","-sdl-","-Gs9999999")
$clfreedebug = $clwx + $clodebug + $cldd + $clfree + $clnortti + $clhash + $cllink + $link + $linkfree
...
$out = "./x86_64-windows-free-cl-debug"
if ("all" -in $targets -or (split-path -path $out -leaf) -in $targets) {
new-item -itemtype directory -force $out | out-null
try {
push-location $out
$buildcount++
write-host (split-path -path $out -leaf)
ml64 @ml $src/example-x64.asm
cl "-Fm./example.map" "-Tc$src/example.c" ./example-x64.obj @cl @clfreedebug
} finally { pop-location ; }
}
If you have an issue, you can easily change compiler options. It will always work and won’t suddenly break if you install a second set of compilers for another project, whereas CMake will have to choose which one and might pick wrong. Likewise, there is no potential for an upgrade to CMake to decide to use different compiler options that interfere with the freestanding stuff. You lose CMake’s abstractions, but like I said, that may be a good thing, depending on what your requirements are, assuming you have detailed knowledge of the compiler (which I’d rather accumulate than detailed knowledge of CMake, and I would know, I have both).Re: 4coder editor is now fully open source
#94Earlier quoted context omitted.
> you should only attempt to be “smart” and search for that type of thing if you really need it — why use any search logic at all, if it can be avoided. vcvars and its modern incarnations exist to facilitate this. But that's the standard for how to do things on Windows. That's how it works. Sure you might not like it, but personally I don't like the implicit assumption that everything is configured and "there" that y…
It’s fine if you want searching, but I disagree that it’s implicitly wrong not to do it because searching is supposedly standard and how everyone else is doing it. Never mind that there exists plenty of software (with far more specific requirements than “give me an object file/dll/executable, compiler version/ABI/options be damned”) that doesn’t use such an approach. For example, try to tell CMake how to create a fre…
What's wrong with target_link_options(foo PRIVATE -static-libgcc -static-libstdc++)
I don't understand how that particular powrshell block is more flexible than cmake from what I can see it does less (it's windows specific - mine works on Linux, Mac, windows, and also works with cross compilation toolchains out of the box). If I want to add specific warnings I can use target_compile_options to get exactly the same behaviour.
> won’t suddenly break if you install a second set of compilers for another project,
I'm genuinely curious - have you used cmake? Cmake has sensible defaults but is completely customizable. Cmake uses platform standards - if you overwrite the CC variable it will use that toolchain instead. Cmake has its warts, for sure, but lack of flexibility is definitely not one of them.
Re: 4coder editor is now fully open source
#95Earlier quoted context omitted.
It’s fine if you want searching, but I disagree that it’s implicitly wrong not to do it because searching is supposedly standard and how everyone else is doing it. Never mind that there exists plenty of software (with far more specific requirements than “give me an object file/dll/executable, compiler version/ABI/options be damned”) that doesn’t use such an approach. For example, try to tell CMake how to create a fre…
> For example, try to tell CMake how to create a freestanding executable (one that doesn’t link to the system C library). You end up fighting against the abstractions inherent in its design. What's wrong with target_link_options(foo PRIVATE -static-libgcc -static-libstdc++) I don't understand how that particular powrshell block is more flexible than cmake from what I can see it does less (it's windows specific - mine…
I’m always the “build system expert” on my team because of how much experience I have. If working on a team where people know the compilers, and where build times are kept reasonable (so not using lots of templates in C++), then on a practical level I recommend not using a build system at all, and just writing a super simple shell script (unity builds are easier there too). I still recommend CMake sometimes though — especially if the main requirement is just “gimme some machine code, who cares how, and who cares about using ASAN, etc.”, and the second most important requirement is to ship the code to the open source community.
BTW, I mean freestanding as in “does not link to any C library”, rather than “statically links to the C library”.
declare -a free=(-std=gnu99 -DEXAMPLE_FREESTANDING -nostartfiles -nostdlib -nodefaultlibs -ffreestanding -fno-stack-protector)Re: 4coder editor is now fully open source
#96Earlier quoted context omitted.
> For example, try to tell CMake how to create a freestanding executable (one that doesn’t link to the system C library). You end up fighting against the abstractions inherent in its design. What's wrong with target_link_options(foo PRIVATE -static-libgcc -static-libstdc++) I don't understand how that particular powrshell block is more flexible than cmake from what I can see it does less (it's windows specific - mine…
I have extensively used CMake since years before it supported the target_ options, and years afterwards. So I was using it before, during, and after the breath of fresh air that was the shift to what is now called “modern CMake”, i.e., bjam/b2 style (define targets with private/public/interface dependencies/options). As you can guess, I’ve also used bjam/b2 extensively. I’ve also used meson to a more limited extent.…
But the minute you introduce someone who is familiar with windows or prefers an IDE workflow this falls apart. You are also limited to the platforms, compilers and IDEs that you write the script to support. That's not flexible, that's inflexible. Also, cmake has supported unity builds out of the box for a few years now [0] and before that cotire existed.
> I mean freestanding as in “does not link to any C library”, rather than “statically links to the C library”.
Ok, great so just use target_compile_optiond in the exact same way as you've just listed the arguments? I don't see how cmake stops you from doing that by architectural decisions at all.
Re: 4coder editor is now fully open source
#97Earlier quoted context omitted.
I fundamentally disagree. The reason programming languages work are because things are consistent, if everyone defined their own flavor of keywords then you're not using the same language anymore. On any project I've worked on I would fail a code review for attempting to introduce something like this.
He is consistent, all functions have that keyword, it's his codebase. He has also has the api(custom) define so his metaprogram knows which functions to publish into the plugin system. C++ syntax is not very regular so if you want to consistently catch all functions with a homemade parser or grep or whatever it would need to be complex, it needs to do backtracking, account for stuff like operator+ etc. If you do what…
Re: 4coder editor is now fully open source
#98Earlier quoted context omitted.
I have extensively used CMake since years before it supported the target_ options, and years afterwards. So I was using it before, during, and after the breath of fresh air that was the shift to what is now called “modern CMake”, i.e., bjam/b2 style (define targets with private/public/interface dependencies/options). As you can guess, I’ve also used bjam/b2 extensively. I’ve also used meson to a more limited extent.…
> then on a practical level I recommend not using a build system at all, and just writing a super simple shell script (unity builds are easier there too). But the minute you introduce someone who is familiar with windows or prefers an IDE workflow this falls apart. You are also limited to the platforms, compilers and IDEs that you write the script to support. That's not flexible, that's inflexible. Also, cmake has su…
As for editors and whatnot, I’ve worked on teams where people used Visual Studio, vim, CLion, VS Code, via these scripts. Most with full IDE integration, some without (some people don’t use it). The easiest pathway is to generate compile_commands.json — ironically, this is already something extremely close to the script, so it’s trivial to automatically generate from the script.
I was just saying as a postscript that I meant something different by freestanding. I agree that it’s totally orthogonal to your argument and mine.
Re: 4coder editor is now fully open source
#99Earlier quoted context omitted.
He is consistent, all functions have that keyword, it's his codebase. He has also has the api(custom) define so his metaprogram knows which functions to publish into the plugin system. C++ syntax is not very regular so if you want to consistently catch all functions with a homemade parser or grep or whatever it would need to be complex, it needs to do backtracking, account for stuff like operator+ etc. If you do what…
The API custom define is perfectly fine. (Well it sucks but that's not his fault, that's a c++ language deficiency). But making custom defines for fundamental types and for language keywords because you'd rather type internal than static is just messy.
Re: 4coder editor is now fully open source
#100Earlier quoted context omitted.
If text files are holding you back. Smalltalk exists...
What do you mean by that?