05/30/2017
I am not certain you can use “C” to develop OPC COM applications since the OPC proxy/stubs have C++ constructs in them such as classes and interfaces. Did you mean C++?
There is a simple C++ client sample in this download:
https://opcfoundation.org/deve…..e-servers/
It is only available to OPC Foundation members.
02/24/2014
Actually, the header files generated by the MIDL compiler (including those that OPC Foundation already distributes such as opcda.h; or you can generate from the .IDL files) can be fed into plain C compiler. The definitions emitted by the compiler look e.g. like this:
#if defined(__cplusplus) && !defined(CINTERFACE)
….
#else /* C style interface */
….
#endif
with the main differences being that there is an additional “This” argument to each method call, ‘struct’-s are used instead of interfaces, and instead of ‘virtual’, pointers to functions are used.
So, you can look for C++ examples instead, and then translate them to C relatively easily. It’s mainly/just syntactic differences. Not that it would be a fun work to do; and the resulting code won’t look nice either.
1 Guest(s)