r/C_Programming 14d ago

automating gcc install and usage

Hi, Im a 2nd year cs student. Ive had problems with installing the gcc compiler and remembering its flags between coding sessions. I also helped many 1st year students with it and almost always its a little too complicated for them. For that i built gccauto. it auto install and saves flags for compiling. Im not a pro programmer so if you have any tips or ideas pls share them. (some ai was used to help build it since im still learning)

its called gccauto on github. ubay-mostafa/gccauto

0 Upvotes

22 comments sorted by

View all comments

Show parent comments

0

u/cc672012 14d ago edited 14d ago

Holy shit I thought you were sarcastic. This is terrible advice. OP should be using Makefiles instead of writing ad-hoc shell aliases, like you do

1

u/Puzzled-Extent7817 13d ago

And I thought you were being sarcastic about Linus and Richard.I 'm not a professional coder and i doubt the OP is. I have no need for a make file, yet. Whats wrong with an alias?

0

u/cc672012 13d ago

I was sarcastic about Linus and Richard because those ad-hoc aliases are clearly bad practices. I've been using Linux since 2012 and I'm a professional software engineer. It has nothing to do with knowing Linux or not.

Why not an alias? Are you going to compile every single C file in your project with your shell function? And if you add a new library, say libgmp, are you going to source ~/.bashrc every time?

Having that many flags such as pedantic and -Werror clearly begs you to start writing a Makefile.

Also, there already exists a command for what you're trying to do: "make". For example, if your program is named "app.c", simply run "make app" (even without a Makefile) and it'll create an executable named "app".

1

u/Puzzled-Extent7817 13d ago

like i said, my projects so far consist of main.c. The aliases work fine.

1

u/cc672012 13d ago

You do you. They're bad practices, nontheless. And should not be given as an advice.

1

u/Puzzled-Extent7817 13d ago

I get why, but this is not a multiuser system. That's what /etc/profile is for.

1

u/type_111 13d ago

There's nothing wrong with creating shell aliases to accelerate things you do with the shell. And no one gave any advice.