#im making my first c++ program and have an error

59 messages · Page 1 of 1 (latest)

solid magnet
#

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\v\OneDrive\Desktop\loim\holy.cpp).

this is the error, and the code is:
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
}

molten burrowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

solid magnet
#

i am also having the error:
cannot open source file "iostream". Please run the 'Select IntelliSense Configuration...' command to locate your system headers.

valid forge
#

Your using int to define the function, that means it is expecting a value to return out of the function. To fix this do:

#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}

OR

#include <iostream>
void main() {
std::cout << "Hello, world!" << std::endl;
}

Voids do not expect anything to return out of them.

solid magnet
#

i see

#

but no

#

i tried both things

#

the errors are still there

#

@valid forge

valid forge
solid magnet
#

In vscode

#

Also, its just showing up in the dubbegger

#

Im not running it

#

Yet

latent bobcat
#

OP's error is due to a misconfiguration of vscode

#

if you are using windows, I would advise you use visual studio 2022 instead of vscode

#

also, for future reference

molten burrowBOT
#
How to Format Code on Discord
Markup

```cpp
int main() {}
```

Result
int main() {}
solid magnet
#

plzzzz

latent bobcat
#

sure, read the documentation and figure it out ^^

solid magnet
#

: (

#

womp

latent bobcat
#

the reason we recommend VS2022 over vscode is so that you can focus on learning what you actually care about (the language), rather than to have to learn literally everything else before even getting hello world to work

solid magnet
#

i see

latent bobcat
#

here's a tutorial, if you really insist on using vscode

solid magnet
#

but you still havent ansered exactly why it wont work in vscde
or why hello world wont work in it

latent bobcat
#

because you didn't configure it properly

#

it can work in vscode, it's just a huge amount of work that can be quite overwhelming, when VS2022 is literally just a few clicks and works ootb

solid magnet
#

hmm

#

ill check

#

so visual studio has its own compiler for it?

latent bobcat
#

yes, msvc

#

it also comes with great debugging and profiling tools

valid forge
#

Visual studio is great because it has all the stuff to run and debug code build into it

solid magnet
#

what other things can u do in vs

valid forge
#

U don’t need to return a value for an int function, but it is a good thing to do.

latent bobcat
#

you need a return value for any non-void function, the only exception being main, where return 0; is added by the compiler if it is omitted from the code

valid forge
latent bobcat
# solid magnet what other things can u do in vs

there's hot reload that is pretty cool, the fact that you don't have to deal with a build system (directly) is something I've always appreciated, even if it's a limiting factor. You can also use it for some other languages

latent bobcat
valid forge
#

Even if it’s the main function

latent bobcat
#

it does hurt to say "you don't need to return from a non-void function" tho

#

because it is incorrect

valid forge
#

I said for a void function

#

I don’t need return for a void function

latent bobcat
#

and main isn't allowed to be void (except through non-standard compiler extensions)

valid forge
#

Rly, I’ve always used void

valid forge
#

Oh, idk why mine lets me then

#

Wierd

#

Must be some libraries I have installed or something

latent bobcat
#

because it's a non-standard compiler extensions

#

enable strict conformance and it won't work