UKC

"C" compiler

New Topic
This topic has been archived, and won't accept reply postings.
 LastBoyScout 04 Apr 2022

Can anyone recommend me a simple, free, C compiler, please?

I'm trying to remind myself of my C skills and it's been a long time since I've used one.

Thanks,

Removed User 04 Apr 2022
In reply to LastBoyScout:

How about onlinegdb which is web based and quick to access.

Is it c or c++ or both you're looking for?

Visual studio community is free and at the powerful end of things. Visual Code is also another free option.

Post edited at 17:16
 a crap climber 04 Apr 2022
In reply to LastBoyScout:

Apologies these are both c++ compilers not c, but depending on what you're doing this might not be an issue.

Microsoft visual studio community would be my top suggestion. I haven't used this for a long time, it used to be called 'Visual Studio Express' but seems to have been rebranded. I still use the paid version though for work from time to time and IDEs don't really get much better than this in my experience.

https://visualstudio.microsoft.com/vs/community/

A good alternative would be Dev C++

https://www.bloodshed.net/

OP LastBoyScout 04 Apr 2022
In reply to a crap climber:

Thanks - I've actually got Visual Studio Professional 2019 on my laptop, as I'm dabbling with C#.NET at work, but wanted something simple and command line for tinkering with a standalone bit of C.

I'll try running it through VS 2019 and see what happens.

 mondite 04 Apr 2022
In reply to LastBoyScout:

> I'll try running it through VS 2019 and see what happens.

If you have installed the c module for VS then you will be able to run the compiler from the command line rather than launching the IDE.

 Cobra_Head 04 Apr 2022
In reply to LastBoyScout:

I'd go for Bloodshed too, dead easy to use no issues with projects and hard to follow user interfaces.

 philipivan 04 Apr 2022
In reply to LastBoyScout:

Assuming you only want the compiler, you didn't mention an ide you can just install gcc on Windows as a command line tool and it'll compile both c and c++ as required. Uses cygwin.

https://gcc.gnu.org/install/binaries.html

 planetmarshall 04 Apr 2022
In reply to LastBoyScout:

> Can anyone recommend me a simple, free, C compiler, please?

Clang or GCC.

Microsoft do not make a C compiler. MSVC is a C++ compiler as you will rapidly discover if you try to compile strict C code.

 Rob Parsons 04 Apr 2022
In reply to LastBoyScout:

> Can anyone recommend me a simple, free, C compiler, please?

gcc

OP LastBoyScout 04 Apr 2022
In reply to planetmarshall:

> Clang or GCC.

> Microsoft do not make a C compiler. MSVC is a C++ compiler as you will rapidly discover if you try to compile strict C code.

After posting, I found I'd got Visual C++ installed, but that just throws up loads of errors on my C code.

 coinneach 04 Apr 2022
In reply to LastBoyScout:

I have no idea what any of this means . . . . .

8
 smbnji 04 Apr 2022
In reply to LastBoyScout:

> After posting, I found I'd got Visual C++ installed, but that just throws up loads of errors on my C code.

Make sure you're setting the compiler to C and not C++, despite the similarities they are not always entirely cross compatible.

https://en.m.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

 planetmarshall 04 Apr 2022
In reply to smbnji:

> Make sure you're setting the compiler to C and not C++, despite the similarities they are not always entirely cross compatible.

You may, or may not, be able to compile C code with MSVC. It supports the C89 standard, and has some support for C99 and C11 but is buggy and not fully compliant.

For a frustration-free experience you will be better of with GCC or Clang.

Clang can be used from within the Visual C++ environment.

OP LastBoyScout 04 Apr 2022
In reply to smbnji:

> Make sure you're setting the compiler to C and not C++, despite the similarities they are not always entirely cross compatible.

How the heck do you change that - I can't see an obvious option?

 freeflyer 04 Apr 2022
In reply to LastBoyScout:

> How the heck do you change that - I can't see an obvious option?

You don't need to. If your source file ends in .c it will compile as C.

Look for something like "Developer Command Prompt for Vs 2019" in the Windows menu Visual Studio folder and run that.

Then make a file called test.c containing the following standard program [wikipedia]:

#include <stdio.h>
int main(void)
{
printf("hello, world");
}

Enter "cl test.c" in the Command Prompt. That should compile without errors. Then run test.exe

edit: The ukc editor removes backslashes from text :/ Normally world would have backslash n after it in order to insert a newline.

Post edited at 22:05
 smbnji 04 Apr 2022
In reply to LastBoyScout:

Not sure I'm afraid, I don't write C very often, and when I do I use `gcc`

However some light googling shows

https://docs.microsoft.com/en-us/cpp/build/reference/compiling-a-c-cpp-prog....

Or as freeflyer says, making sure your extension is .c

This page looks like it might be helpful for what you're trying to achieve too

https://docs.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-...

 EddInaBox 04 Apr 2022
In reply to freeflyer:

> edit: The ukc editor removes backslashes from text :/

How annoying. \n

 wintertree 04 Apr 2022
In reply to Rob Parsons:

> gcc

Clang/LLVM.  Far more informative error messages and displayed with great clarity on a terminal (as the OP indicated they’re looking to work from).

 freeflyer 05 Apr 2022
In reply to EddInaBox:

> How annoying. n

Haha I've no idea how you did that. However seeing as posting code in ukc isn't really a thing, I'm not so worried ... Occasionally it also seems to remove anything in angle brackets, presumably in some desperate attempt to avoid html injection etc.

 EddInaBox 05 Apr 2022
In reply to freeflyer:

Backslash seems to be an escape character, so double backslash works.  \\ -> \

 Philip 05 Apr 2022
In reply to Rob Parsons:

> gcc

Is the correct answer

 freeflyer 05 Apr 2022
In reply to LastBoyScout:

> Can anyone recommend me a simple, free, C compiler, please?

> I'm trying to remind myself of my C skills and it's been a long time since I've used one.

You don't say what your motivation is for reminding yourself about C (a dubious enterprise which has however earned me a substantial amount of money over the years).

If it's career-related, it may be worth taking a look at Rust, which is making the language fanbois so excited, and has caused Linus to observe cautiously that Rust is "the first language I saw which looked like this might actually be a solution".

1
 hokkyokusei 05 Apr 2022
In reply to LastBoyScout:

GCC is the obvious choice, available, free on many platforms.

On no account be tempted to use the compiler that comes with the Death Station 2000.

In reply to freeflyer:

> presumably in some desperate attempt to avoid html injection etc.

You think we should allow HTML injection?

 camstoppa 11 Apr 2022
In reply to LastBoyScout:

gcc - look no further

2
 freeflyer 11 Apr 2022
In reply to Paul Phillips - UKC and UKH:

> You think we should allow HTML injection?

Haha the "desperation" referred to the issue that sometimes it removed the angle bracket stdio.h angle bracket in my C code post above, and sometimes it didn't!

Slack and the like have a code snippet block which allows unformatted unsanitised text to be posted, but as I suggested earlier, it seems less likely that anyone will need to be posting code snippets of any kind on the forum, so I'm thinking there are no user requirements and whatever you're doing in the way of security should be driven by proper threat detection and removal. UI isn't really my thing so I don't have much knowledge of what gets used commercially, sorry.

 wintertree 11 Apr 2022
In reply to Paul Phillips - UKC and UKH:

> You think we should allow HTML injection?

What about a paid service offering an API access to people wanting to run hundreds of accounts?  He says, casting a critical eye over this thread…

With reference to discussions about posting code, I’d far rather have an option to put latex in a post and have it rendered inline as an image…. Probably a sign that some threads belong on Stack Overflow instead…

Post edited at 14:09

New Topic
This topic has been archived, and won't accept reply postings.
Loading Notifications...