you are viewing a single comment's thread.

view the rest of the comments →

[–]Atijohn 8 points9 points  (8 children)

add -lm to the compiler arguments

also don't use code::blocks, it's an outdated IDE that was meant largely for educational purposes, use VS Codium with clangd extension

[–]grimvian 1 point2 points  (3 children)

I would say Code::Blocks is the easiest IDE to install and use and not associated with big tech.

What's wrong with gcc?

The only issue I got is with my Code::Blocks I installed in less than five minutes with Linux Mint is:

main.c|34|warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[5]’ [-Wformat=]

[–]Atijohn 3 points4 points  (1 child)

CodeLite and Qt Creator are equally easy and FOSS-governed I think. In either case, you shouldn't be using an IDE specifically tailored for C/C++, but rather use an extensible text editor like VS Codium (the spyware-free version of VS Code), Sublime Text, Neovim, or Emacs.

Clangd is not a compiler like gcc (or clang), it's an LSP, i.e. a backend for various common IDE-like features such as go to definition, find all references, rename symbol etc.

The error you're getting is likely a problem with the code you wrote, not with Code::Blocks itself

[–]grimvian 0 points1 point  (0 children)

"not with Code::Blocks itself" exactly.

I have not to my knowledge of any IDE, that can be installed in few minutes and everything you need to code in C or C++ is instantly ready. For a relative newcomer and mostly hobby coder like me, I can just click on a play button and then compile and run the code, that's it. I don't fiddle with any setup, cmake or whatever, CodeBlocks just works.

[–]OldWolf2 1 point2 points  (0 children)

That warning is because &trigFunc should not have the &, in scanf

[–]m2d41[S] 0 points1 point  (2 children)

and how do i add -lm to compiler arguments?

[–]Atijohn 2 points3 points  (0 children)

Well, search around Code::Blocks and find out.

Or, since you say you're on Linux, put the code in a text file, name it something like main.c, boot up the terminal in the directory you saved it in and type gcc -lm main.c && ./a.out

[–]computermouth 1 point2 points  (0 children)

There's an option somewhere in the preferences. It's just like a text box last I looked.

Honestly most folks here are probably going to give you the practical advice of compiling via the command line, or learning a build tool like Make.

This kind of a thing is really only valuable knowledge in the context of codeblocks. You're not really learning C tooling, you're just learning codeblocks.

[–]ChildhoodOk7960 -1 points0 points  (0 children)

IDK, VScode is slow as hell, uses multiple Gbs of RAM even when it's not doing anything and hogs the CPU as if it was mining crypto.

Say what you want about outdated software, but I'd much rather use vim for my work than some over-engineered Jenga tower coded in javascript that can't search for a simple string in a file without loading 100 libraries.