#VSCode and C
166 messages · Page 1 of 1 (latest)
@rich hornet has reached level 4. GG!
Ok
Did you install c/cpp extension
Ok when you click the green button its going to tell you to choose compiler
As far as i know gcc is for C
And g++ is for C++
Play button on the top right
Try switching to another file and going back to the source file it gets hidden sometimes
Or you messed something up while trying to setup C on VSC 💀
Oh you dont know how to use vsc 😭
Well there should be a green ▶️ button
That compiles and runs the code
.
Bro send ss 💀
Bruh i dont remember such a thing
@visual pumice has reached level 49. GG!
50 BEFORE GETTING BANNED 🔥🔥
show a screenshot of your full window please
your running button is on the top right, it's just not green 🙂
left to the settings icon
select the first one
here's a thought: compile via command line 👍
is gcc in path?
cmd -> gcc --version
then click on open launch.json
but it opened a json 👀
good
what?
lol
find the json in your directory
in your .vscode folder
I forgor
or just dont use vscode
install mingw
and shit
did you open a file or folder in vscode?
cmake sucks
😂
ming's is gaA use WSL, already built into windows
@worthy timber has reached level 4. GG!
Meson is better tbh
cmake is baddddd
@oblique ingot How does your contribution to this chat help getting the issue solved? It's annoying for the questioner if the topic of the help-post gets changed...
can you send me a screenshot of your projects folder please?
why is there a random void parameter
that's usually good practice in C meaning the function doesn't accept any parameters, because int foo(); would mean accept any number of parameters of any type, although this is removed in C23 i believe
strange
because VOID can also be used to express any datatype
i might however be wrong
personally i use only c++
i also dont think you can pass random arguments unless you do args[] i thought?
which would mean any arguement
@young patio
like
int main(args[])
that's a void pointer
shoot bro
ive been
working with windows api
for
8 hours straight
my bad lolz
i think im going insane hah
void is what's known as the type-0 because it there's no value of that type
unlike say a bool which has two possible values
yeah, 1 or 0
there's a difference between program arguments and function arguments
here's an example:
#include <stdio.h>
int foo();
int main(void){
printf("%d\n", foo(2, 3, 4));
return 0;
}
int foo(int a, int b){
return a + b;
}
this compiles in c just fine
;compile
5
wym struct?
typedef struct to store a and b
;compile cpp
typedef struct(
int a;
int b;
) numberos;
<source>: In function 'int main()':
<source>:6:23: error: too many arguments to function 'int foo()'
6 | printf("%d\n", foo(2, 3, 4));
| ~~~^~~~~~~~~
<source>:3:5: note: declared here
3 | int foo();
| ^~~
Build failed
that doesn't really make sense for this particular case
i mean, it depends
if there's a good reason to pack everything into a struct, then yeah
well, i only use it because i work with low level windows internals
i personally
like
neat code
like for example a cartesian point would make sense
anything where you need to store a ton of data types
but like a function that computes the greater of two integers not so much
cant you just do that in int main????
the hell do you mean?
drugs
read. it was about argument passing.
you don’t pass an arguement to yourself lol
Does declaring a function with no args let you make multiple definitions with different args after? I didn’t know you could do what you wrote here before.
I knew that not listing parameters was declaring that any params could be passed, but I didn’t know the definition didn’t have to exactly match.
no, you generally can't have multiple definitions of the same symbol in C
the difference is actually clearer when you understand the different between parameter type lists and identifier lists:
// using parameter type lists
// a declaration
int max(int a, int b);
// a definition
int max(int a, int b){
//...
}
// using identifier lists
// a declaration
int max2();
// a definition
int max2(a, b) int a; int b; {
//...
}
using identifier lists, the declaration can't specify it's parameters, meaning such declaration only says that max2 returns an int but may take in any number of arguments of any type, they're just not known
keep in mind that max2 can therefore be called using any number of arguments but it's undefined behavior to do so
@rich hornet has reached level 5. GG!
there is the .vscode folder i was talking about
@rich hornet i strongly reccomend just using visual studio
visual studio is better anyway
i reccomend swapping
visual studio also allows you to easily install development kits, far better than VSC
it's different, but way easier to get started with
it’s just
a better IDE in general
i only use VSC for high level programming
vscode is no ide
well
in context, it’s being used as one
so
vs is better
it takes up more space but it also has literally everything you could possibly need
i wouldn't say it this way, but i know what you want to say
There's an interesting debate on whether we should treat the void type as containing zero values or one single value (similar to an empty struct): https://en.wikipedia.org/wiki/Void_type
I'm inclined to say it is a zero-type because you can't instante it
void foo {}: // not possible
the wikipedia page mentions the () unit type in haskell as similar but in fact that type has one possible value:
void :: ()
void = ()
Afaik haskell functions should always return variable
use visual studio
what's the exact reason again why you are not using visual studio?
when you try to run in vscode without a conf then it creates one
and you can modify it to compile and run your code
but visual studio is easier to get started as a beginner so good for you when you are lazy 🤔
you can make it execute a bash command as soon as you click on the start icon
same as when you would compile and start with your terminal
For me it interface is too much overcomplicated
of visual studio? hmm i understand that
but you can just use what you need
i don't like visual studio that much myself to be honest
yes, you have to set this up in your configuration file
@rich hornet take a look at https://code.visualstudio.com/docs/languages/cpp
@rich hornet çözdünmü sorunu
ire fotodan
That's interesting. I didn't know about the identifier list syntax before. I can see why you can't use identifier list syntax in a declaration as well.
Is it the case that identifier list syntax was "the original" syntax, and that parameter type lists came afterwards? I might google that later, but I'm curious about why both are possible in the language.
@visual pumice take a look this
yeah
originally the creators of C thought it was too much of a hassle having to specify the type in paremeter lists
so this exists purely for backwards compatability
rel
Thanks for explaining, I used to do it in code golf challenges before (without specifying the type), but I didn't understand the full extent of this syntax.
yeah, it's a bit of historical baggage that was kept in the language for more time than it should
I've learned C++ first, all I know about C is from experimenting and looking at golf programs from others 😄
But I can still write a 5 characters valid program in C, which compiles, runs and generates a segfault 😄
5? including int main()?
5 characters in total, including everything
care to show? lol