Log in

View Full Version : NetworkTables compile issues


DanG100
21-03-2016, 18:52
I'm trying to use network tables in C++ on windows, using Visual Studio.
After building with gradle and including the proper directories, I get several errors.

Error 5 error C4996: 'ITable::GetNumber': Raises an exception if key not found; use GetNumber(StringRef key, double defaultValue) instead C:\ntcore\include\networktables\NetworkTable.h 477 1 GoalDetection


I get similar error for GetString and GetBoolean

jreneew2
21-03-2016, 18:58
All you have to do is use the same function with different parameters. Instead of:

table->GetNumber("x");

do this instead

table->GetNumber("x", 0.0);

This just sets a default value for that value in the table in case the robot is not connected to the driver station yet. If it didn't it would throw an exception, like it says in the error.

DanG100
21-03-2016, 19:10
The error I'm getting is in NetworkTable.h, I got the error as soon as included the file.

jreneew2
21-03-2016, 20:58
Have you looked at this link:

https://wpilib.screenstepslive.com/s/3120/m/7912/l/80205-writing-a-simple-networktables-program-in-c-and-java-with-a-java-client-pc-side

It is for java, but I'm sure you could easily translate it.