wpilibsuite / ntcore

NetworkTables Core Library (ARCHIVED, merged into allwpilib)
Other
39 stars 28 forks source link

Cannot use C interface with gcc #273

Closed rjbell4 closed 6 years ago

rjbell4 commented 6 years ago

Despite appearing to support a C API, the ntcore_c.h file is not usable with a C compiler. That's primarily because it #includes <cstddef>, and because it presumes that structs are implicitly typedefed.

ThadHouse commented 6 years ago

The reason is the c API is primarily for interop between other languages. So it's more to create an API with the C abi, rather then be directly usable from C itself. Is there a specific reason you need to use the header from C?

rjbell4 commented 6 years ago

We are running a C-based program on co-processor for use in FRC. Recent developments have us wanting to be able to take action based on a state determined by the robot. So we want the robot to write to a Network Table, and the C-based program it be able to pick up those change. Therefore, we'd like to be able to read from Network Tables in C.

The changes seem pretty simple; they appear to just be oversights. I created PR #274 for the changes I made that allow us to compile the C code with gcc, instead of g++.

rjbell4 commented 6 years ago

Release build issue? I can't get through a release build with warnings (treated as errors) on my machine without my modification. Try a slightly less less invasive change, though, to see if that fixes the issue...

ThadHouse commented 6 years ago

That issue happens on Travis, and we haven't been able to fix it yet because of the old release of gcc Travis has. I'll test it locally and make sure it builds, then we can push it to build on our main servers.

rjbell4 commented 6 years ago

Hmm, OK. I moved the more C-stuff inside the __cplusplus ifdef, just in case. Let me know if you want it taken back out and made universal.

PeterJohnson commented 6 years ago

Fixed in wpilibsuite/allwpilib#1007.