Closed thewhitecat closed 6 years ago
After staring at this problem for a few hours, I guess I just needed some sleep...I forgot to set compilerPath
I didn't realise I had to set the compilerPath
. For those who find who also stumble on this issue, take a look at this document. The compilerPath
needs to be set and intelliSenseMode
needs to be set to clang-x64
. Here's my configuration as an example;
{
"configurations": [
{
"name": "MinGW",
"compilerPath": "C:/Users/Steven Upton/scoop/apps/gcc/current/bin/g++.exe",
"includePath": [
"${workspaceFolder}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 3
}
worked for me what stwupton had told. thanks man.
thanks man worked for me too
[issue moved]
@leslienguyn, I moved your issue to #2582.
Is there a VS code for mac version of this?
@TallOrderDev VS Code (and our extension) is available for Mac.
I hava this same problem but I do not know how to write a compiler path please help
@Yguy16 You set the "compilerPath" setting to the path to your compiler. What OS/compiler are you using?
vs code @sean-mcmanus
@sean-mcmanus im windows do i not have a compiler than?
@Yguy16 You can use many different compilers on Windows, but if you're using cl.exe or a WSL compiler, then we usually should auto-detect that and you shouldn't need to set a compilerPath unless you want to add compiler arguments. See https://code.visualstudio.com/docs/cpp/config-msvc , or https://code.visualstudio.com/docs/cpp/config-wsl, or https://code.visualstudio.com/docs/cpp/config-mingw .
I dont know why it is not auto detecting @sean-mcmanus. It does it on my mac but i think I fixed by disabling the squigle lines
@Yguy16 You may not have a compiler installed? You can run the C/C++: Log Diagnostics command to see what compiler path we are auto-detecting.
I do think I have a compiler on my windows but it does not have the same error while testing on my mac @sean-mcmanus so should I just stick to coding on my mac?
@sean-mcmanus this is the basic cpp cod I have and it says 'g++' is not recognized as an internal or external command, operable program or batch file.
using namespace std; int main() { std::cout << "helloworld\n";
return 0;
}
@sean-mcmanus I ran a similar piece of code on my mac and it worked so ill stick to that thank you
Above @stwupton provides a config example for windows, which has worked on my windows machine. I'm curious if there is a Mac version of this solution. As I also work with VS code on mac and would like to not have to vm to windows to use VS Code for C++.
@TallOrderDev See https://code.visualstudio.com/docs/cpp/config-clang-mac . If you have specific question/problem on Mac, please file a new issue. Yguy16 seemed to be unable to build on Mac.
It is very complex, I am trying to resolve my electronic problem in C++ and I do not have time to resolve configurations problems. Is there another debugger? Please.
@robrey , please file new issues about the specific configuration problems and debugger.
For the configuration issue, please provide logs from running the C/C++: Log diagnostics
command.
For debugger issue, please provide copies of your tasks.json
and launch.json
files if you have them.
I am running .cpp file on VS Code to compile and run it. But I don't know how to setup VS code environment for it to debug. I have run the following code on it and it gives me these errors:
cannot open source file "Adafruit_Fingerprint.h" `/*** This is a library for our optical Fingerprint sensor
Designed specifically to work with the Adafruit Fingerprint sensor ----> http://www.adafruit.com/products/751
These displays use TTL Serial to communicate, 2 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****/
#include <util/delay.h>
#include <SoftwareSerial.h>
Adafruit_Fingerprint::Adafruit_Fingerprint(SoftwareSerial *ss) { thePassword = 0; theAddress = 0xFFFFFFFF;
hwSerial = NULL; swSerial = ss; mySerial = swSerial; }
Adafruit_Fingerprint::Adafruit_Fingerprint(HardwareSerial *ss) { thePassword = 0; theAddress = 0xFFFFFFFF;
swSerial = NULL;
hwSerial = ss; mySerial = hwSerial; }
void Adafruit_Fingerprint::begin(uint16_t baudrate) { delay(1000); // one second delay to let the sensor 'boot up'
if (hwSerial) hwSerial->begin(baudrate);
if (swSerial) swSerial->begin(baudrate);
}
boolean Adafruit_Fingerprint::verifyPassword(void) { uint8_t packet[] = {FINGERPRINT_VERIFYPASSWORD, (thePassword >> 24), (thePassword >> 16), (thePassword >> 8), thePassword}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, 7, packet); uint8_t len = getReply(packet);
if ((len == 1) && (packet[0] == FINGERPRINT_ACKPACKET) && (packet[1] == FINGERPRINT_OK)) return true;
/ Serial.print("\nGot packet type "); Serial.print(packet[0]); for (uint8_t i=1; i<len+1;i++) { Serial.print(" 0x"); Serial.print(packet[i], HEX); } / return false; }
uint8_t Adafruit_Fingerprint::getImage(void) { uint8_t packet[] = {FINGERPRINT_GETIMAGE}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, 3, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1; return packet[1]; }
uint8_t Adafruit_Fingerprint::image2Tz(uint8_t slot) { uint8_t packet[] = {FINGERPRINT_IMAGE2TZ, slot}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1; return packet[1]; }
uint8_t Adafruit_Fingerprint::createModel(void) { uint8_t packet[] = {FINGERPRINT_REGMODEL}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1; return packet[1]; }
uint8_t Adafruit_Fingerprint::storeModel(uint16_t id) { uint8_t packet[] = {FINGERPRINT_STORE, 0x01, id >> 8, id & 0xFF}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1; return packet[1]; }
//read a fingerprint template from flash into Char Buffer 1 uint8_t Adafruit_Fingerprint::loadModel(uint16_t id) { uint8_t packet[] = {FINGERPRINT_LOAD, 0x01, id >> 8, id & 0xFF}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
return -1;
return packet[1];
}
//transfer a fingerprint template from Char Buffer 1 to host computer uint8_t Adafruit_Fingerprint::getModel(void) { uint8_t packet[] = {FINGERPRINT_UPLOAD, 0x01}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
return -1;
return packet[1];
}
uint8_t Adafruit_Fingerprint::deleteModel(uint16_t id) { uint8_t packet[] = {FINGERPRINT_DELETE, id >> 8, id & 0xFF, 0x00, 0x01}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
return -1;
return packet[1];
}
uint8_t Adafruit_Fingerprint::emptyDatabase(void) { uint8_t packet[] = {FINGERPRINT_EMPTY}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1; return packet[1]; }
uint8_t Adafruit_Fingerprint::fingerFastSearch(void) { fingerID = 0xFFFF; confidence = 0xFFFF; // high speed search of slot #1 starting at page 0x0000 and page #0x00A3 uint8_t packet[] = {FINGERPRINT_HISPEEDSEARCH, 0x01, 0x00, 0x00, 0x00, 0xA3}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1;
fingerID = packet[2]; fingerID <<= 8; fingerID |= packet[3];
confidence = packet[4]; confidence <<= 8; confidence |= packet[5];
return packet[1]; }
uint8_t Adafruit_Fingerprint::getTemplateCount(void) { templateCount = 0xFFFF; // get number of templates in memory uint8_t packet[] = {FINGERPRINT_TEMPLATECOUNT}; writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet); uint8_t len = getReply(packet);
if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET)) return -1;
templateCount = packet[2]; templateCount <<= 8; templateCount |= packet[3];
return packet[1]; }
void Adafruit_Fingerprint::writePacket(uint32_t addr, uint8_t packettype, uint16_t len, uint8_t *packet) {
Serial.print("---> 0x"); Serial.print((uint8_t)(FINGERPRINT_STARTCODE >> 8), HEX); Serial.print(" 0x"); Serial.print((uint8_t)FINGERPRINT_STARTCODE, HEX); Serial.print(" 0x"); Serial.print((uint8_t)(addr >> 24), HEX); Serial.print(" 0x"); Serial.print((uint8_t)(addr >> 16), HEX); Serial.print(" 0x"); Serial.print((uint8_t)(addr >> 8), HEX); Serial.print(" 0x"); Serial.print((uint8_t)(addr), HEX); Serial.print(" 0x"); Serial.print((uint8_t)packettype, HEX); Serial.print(" 0x"); Serial.print((uint8_t)(len >> 8), HEX); Serial.print(" 0x"); Serial.print((uint8_t)(len), HEX);
mySerial->write((uint8_t)(FINGERPRINT_STARTCODE >> 8)); mySerial->write((uint8_t)FINGERPRINT_STARTCODE); mySerial->write((uint8_t)(addr >> 24)); mySerial->write((uint8_t)(addr >> 16)); mySerial->write((uint8_t)(addr >> 8)); mySerial->write((uint8_t)(addr)); mySerial->write((uint8_t)packettype); mySerial->write((uint8_t)(len >> 8)); mySerial->write((uint8_t)(len));
mySerial->print((uint8_t)(FINGERPRINT_STARTCODE >> 8), BYTE); mySerial->print((uint8_t)FINGERPRINT_STARTCODE, BYTE); mySerial->print((uint8_t)(addr >> 24), BYTE); mySerial->print((uint8_t)(addr >> 16), BYTE); mySerial->print((uint8_t)(addr >> 8), BYTE); mySerial->print((uint8_t)(addr), BYTE); mySerial->print((uint8_t)packettype, BYTE); mySerial->print((uint8_t)(len >> 8), BYTE); mySerial->print((uint8_t)(len), BYTE);
uint16_t sum = (len>>8) + (len&0xFF) + packettype; for (uint8_t i=0; i< len-2; i++) {
mySerial->write((uint8_t)(packet[i]));
mySerial->print((uint8_t)(packet[i]), BYTE);
Serial.print(" 0x"); Serial.print(packet[i], HEX);
sum += packet[i];
}
//Serial.print("Checksum = 0x"); Serial.println(sum); Serial.print(" 0x"); Serial.print((uint8_t)(sum>>8), HEX); Serial.print(" 0x"); Serial.println((uint8_t)(sum), HEX);
mySerial->write((uint8_t)(sum>>8)); mySerial->write((uint8_t)sum);
mySerial->print((uint8_t)(sum>>8), BYTE); mySerial->print((uint8_t)sum, BYTE);
}
uint8_t Adafruit_Fingerprint::getReply(uint8_t packet[], uint16_t timeout) { uint8_t reply[20], idx; uint16_t timer=0;
idx = 0;
Serial.print("<--- ");
while (true) { while (!mySerial->available()) { delay(1); timer++; if (timer >= timeout) return FINGERPRINT_TIMEOUT; } // something to read! reply[idx] = mySerial->read();
Serial.print(" 0x"); Serial.print(reply[idx], HEX);
if ((idx == 0) && (reply[0] != (FINGERPRINT_STARTCODE >> 8)))
continue;
idx++;
// check packet!
if (idx >= 9) {
if ((reply[0] != (FINGERPRINT_STARTCODE >> 8)) ||
(reply[1] != (FINGERPRINT_STARTCODE & 0xFF)))
return FINGERPRINT_BADPACKET;
uint8_t packettype = reply[6];
//Serial.print("Packet type"); Serial.println(packettype);
uint16_t len = reply[7];
len <<= 8;
len |= reply[8];
len -= 2;
//Serial.print("Packet len"); Serial.println(len);
if (idx <= (len+10)) continue;
packet[0] = packettype;
for (uint8_t i=0; i<len; i++) {
packet[1+i] = reply[9+i];
}
Serial.println();
return len;
}
} }
`
Hello, trying to set VS Code up for C++ I ran into a problem. I'm on Win32, MinGW installed.
I just tried a simple Hello World, but VS Code doesn't seem to like:
#include <iostream>
As it gives out 2 problems:
include errors detected. Please update your includePath. IntelliSense features for this translation unit (D:\Dokumente\test.cpp) will be provided by the Tag Parser.
and: cannot open source file "iostream"
I've read issue #1041 but I couldn't solve my problem. My test.cpp:
The Win32 part of my c_cpp_properties.json looks as follows:
From what I can tell "iostream" sits in D:/MinGW/lib/gcc/mingw32/6.3.0/include/c++ Setting intelliSenseMode set to clang-x64 did not help either.
I can compile the program just fine using g++ test.cpp
Thanks for your help.