C on Windows

How can I get started with learning how to program C on Windows? How do I write programs? What do I compile with? What about memory management?

Attached: 51TGEPRTDNL._SX377_BO1,204,203,200_.jpg (379x499, 27K)

Other urls found in this thread:

github.com/prasannavl/WinApi
github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2
twitter.com/NSFWRedditVideo

>How can I get started with learning how to program C on Windows?
Follow a c-in-a-nutshell book and learn modern safe and secure C programming. K&R is not it.
>How do I write programs?
Download visual studio 2019 community and select desktop C programming module.
>What do I compile with?
The built-in compiler. VS has an automated build system, don't worry about it.
>What about memory management?
C has no concept of memory management other than the standard library's *alloc() and free(). You have to decide what memory management means in that language.

download some ide, download gcc and just get going, it's as easy to set up as any other language on windows
Shit like posix threads work on windows too, for whatever reason I was not able to figure out yet

Attached: 1001004006217508.jpg (1080x1266, 85K)

Programming on Windows is a completely unintuitive nightmare. Just use Visual Studio.

use WSL and VS Code. you'll have a linux environment amd they play very well together.

>download gcc

There's no good way to do this on Windows. Mingw and Cygwin are both shit compared to native Linux installs.

have fun with bloated visual studio that's made for c++

Attached: CL4uTorWUAARXEE.jpg (349x356, 23K)

>using windows

Casey Muratori's vids are an unironically God tier WinAPI introduction.

Attached: B5CNsxACIAE1Nah.jpg (768x1024, 124K)

>Mingw and Cygwin are both shit compared to native Linux installs
How so? I got one of my friends to start learning C by just showing him to a MinGW installer, it's working fine for him.

VS2019 with pure C is pretty comfy. If your machine can't handle visual studio's BBC, VSCode might be a good alternative (assuming you can tolerate the extremely autistic adventure required to configure the toolchains correctly).

>everything that doesn't run well on my specific 10 year old second hand computer is bloat
Whoa

Use MS VS developer console. The compiler name is cl.

but WinAPI is anything but Got tier

Core 2 ought to be enough for anybody

WinAPI is god tier if you use it from C# with pass-by-ref wrappers around the native windows DLLs. Performance is virtually identical to calling the same APIs from C/C++, because 99% of the time you are just passing an Int32 handle around. See:

>github.com/prasannavl/WinApi

>Casey Muratori
the handmade hero guy?

>How do I write programs? What do I compile with?
You can use visual studio, it's the best IDE for Windows and how you'd realistically be writing programs if developing for Windows.
>How can I get started with learning how to program C on Windows?
First watch a video or two on how to setup a project in visual studio, basic usage, and more importantly running and testing the program. After which you can use any resource of your choice on C.
>What about memory management?
What about it? Use either the malloc family of functions for dynamic allocation or some of the ones provided by windows (HeapAlloc, VirtualAlloc, etc.)

VSCode is far more resource intensive than Visual Studio.

Go use a i386.

The Win32 API looks comfy but it’s a mess. Just use Linux/GCC and learn Xorg. Once you know Xorg you’ll pretty much instantly know how to use what inevitably replaces it, (wayland might be it, no guarantee)

Xorg is quite literally the definiton of a mess. Completely irrelevant and mindless server-client design.

I would say that really depends a lot on how large your solution/project(s) are. For single project case, yeah VS is probably better (especially considering its a way better IDE in general). I have some solutions with 20+ projects in them and they can run like complete ass sometimes. 3 gig+ memory footprint just loading the damn thing, builds peaking at 12+ gigs.

>C on windows
Just install linux.

>How can I get started with learning how to program C on Windows?
The same way you learn to program C on unix except for implementation defined things with mingw. Read C programming, a modern approach
>How do I write programs?
Any basic text editor Retard
>What do I compile with?
MinGW
>What about memory management?
What about it?

can someone explain why is programming in windows harder than programming in linux? what's the difference if the code is the same?

The code isn't always the same, especially when you start doing OS specific work like file management, multi-threading, etc.
C was originally created as language for implementing Unix, and was used again later for Linux. So Unix/Linux and C are deeply connected. Windows does not have this connection, which sometimes makes things harder to do than on Linux.

PellesC
First compiler to have full C99 and C11 support (100% feature complete, not even gcc and clang has that today)
Compiler, linker, assembler, IDE, debugger, made by one guy.

If you want an "all-for-one" solution for Windows, your best bet is to use Dev-C++. Google that name and download from Sourceforge. There's a way older version that won't even work on modern Windows, avoid that.

Yeah everyone who does Linux programming knows that. It’s going to be replaced with something, maybe Wayland if they can fix the design.

>file management, multi-threading
It's completely standardised in C++17/20.
If anything, it's harder on windows because you can't just tell your package manager to fetch all build dependencies and source code for an app, or manually install every single library that contains 'qt5', for instance.

This is a C thread though, not C++.

C++ is a superset of C, just like my programming abilities to everyone in this thread.

Setting up WSL is extremely easy. Just look up one of the thousands of tutorials on Bash / Command Line usage. The extreme basics would be
```
gcc input_file.c -o output_file
```
To compile and
```
./output_file
```
to run. Either that or just download Visual Studio and do it however they do it.

yyyyyyyeah on visual studio it's hit F5 to build and run.

Yeah, until you want to use a third-party library. Then Windows is a fucking nightmare compared to Linux.

It's way easier than on Linux, just follow the MSDN guides.

this is the most pajeet-level advice I have ever seen

windows subsystem for linux you mouth breathing retard

Attached: unnamed.jpg (900x900, 72K)

Okay refute me.

>How can I get started with learning how to program C on Windows?
Follow any C book, K&R included. Start writing simple programs and look up issues as you run into them. Practice makes perfect.
>How do I write programs?
Download WSL/Mingw/Cygwin. I personally use WSL. On there use a terminal text editor like vim, emacs, or nano
>What do I compile with?
gcc
>What about memory management?
Learn and practice with alloc() and free() because it's the basics of every other memory management system

>Okay refute me
There you go. Any uni will have you doing the steps I have listed, writing in VS is literal cancer and takes away all control you have over your code. If you follow what I have listed, you will have the knowledge and skill to then transition to any language on any environment.

Attached: 1562542913099.jpg (600x600, 95K)

Just open up a Linux VM and use vim to write, and gcc + makefiles to compile.
VS is bloated garbage that imposes Microsoft's build system onto you.

I don't know what these meme about Linux/Unix being better for C comes from.
Windows is a god tier for C, you have stable, known libraries for graphics, sound, GUI, http, and lots more that you can link against and make small (as in executable size) stand alone programs that work from Windows XP up to Windows 10 with no dependencies.

BASED

Attached: b96.png (800x960, 1.5M)

>K&R included
You can and will hit all sorts of 1970s UB and type ambiguity with that book, and worse - get used to it.
>WSL
Yes 1/10th the compiling performance is always enjoyable.
>vim, emacs, or nano
Yes 1/10th the features is always enjoyable. Unless you bloat it up to VS levels but still not VS feature levels.
>all control
What the fuck are you talking about retard?
>bloated garbage
Full of features =/= bloat. You can also use cmake or other make systems.

okay then install linux you fucking troglodyte.

literally what else do you need. K&R IS the standard for a lot of people, I have literally noticed 0 compile performance difference with gcc besides being faster than with VS, and as for vim, emacs and nano I don't know what other functionality you NEED unless you're a retard that needs flashing lights and colors constantly to tell you you're fucking up. Please tell me what you use, I'm actually interested in knowing.

Attached: 1558682333698.jpg (900x900, 73K)

>but it’s a mess
>and learn Xorg
this has to be a troll...right?

>IS the standard for a lot of people
Not good enough.
>noticed
Ohhhhhhhh okay.
>NEED
Visual studio 2019 community.
I need a mouse cursor because after years of gaming I can twitch click as fast as I can look at something. Other than that I prefer the GUI to select the current build configuration and project defaults. The tooltips on visual studio is insane, you can do anything from jump to definition to automatically making a struct/class with its own header and source with all includes and guards. On C++ I also enjoy selecting a few types of my choosing for my templates so that the linter picks up compile errors on the spot. No other IDE on the planet has this last feature. Other than that it's much simpler to manage compilation flags with toggles and switches, no typos or manuals lookups. It's also one big package that autoupdates and I don't need to learn a single key combo other than some function keys. Of course VS supports autistic keybindings.

Y'all just need to acknowledge that Plan 9 is the best C dialect.

Can someone explain to me why each operating system needs its own unique set of C libraries?

Can someone explain to me why each C library targets its own unique set of operating systems?

You will never be a coder you probably live in your mom's basement and trying to make money by programming you are obviously a failure because your on Jow Forums go get a fucking life

lol

>REEEEEEEE LEARNING IS BAD THINK ME NO LIKE

Get clang, use single header libraries only.
Compilation should be just basically passing clang the main file, and some includes and shit.

This works, even for larger projects, and compiles super quickly.

Just use Dev C++ bro

>jump to definition
you don't actually think that's a breakthrough do you
>templates fuckery
I have no fucking idea what you're on about. I doubt your environment catches compile errors before compile time
>compile flags
Just store them in some variable defined in some text file, surely you don't need anything easier than that

all of you are fucking retards
hey OP, github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2