stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.33k stars 1.71k forks source link

#define ON 1 causes problems with other packages. #132

Closed MartinMohan closed 10 years ago

MartinMohan commented 11 years ago

Hi, I wanted to use libmodbus on debian wheezy with the tango control system but there is a conflict in modbus.h with

define OFF 0

define ON 1

To get both packages working together I modify ON/OFF to MODBUS_OFF/ MODBUS_ON in modbus.h ( When you recompile the compiler tells you which c programs must be updated with these new values). I also reported this to other package... http://www.esrf.eu/mail_archives/tango/archive/msg05002.html

stephane commented 11 years ago

It makes sense and I think I can change it in libmodbus 3.1.1 (for next stable v3.2)

stephane commented 10 years ago

libmodbus checks the OFF and ON aren't already defined so why there is a conflict?

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef OFF
#define OFF 0
#endif

#ifndef ON
#define ON 1
#endif

Which version do you use?

stephane commented 10 years ago

@MartinMohan ping

ghost commented 10 years ago

Unfortunately tango does not seem to use preprocessor directives for defining their constants. From tango code tango-8.1.2c.tar.gz (http://sourceforge.net/projects/tango-cs/files) The file defining constants is...... tango-8.1.2/lib/cpp/server/tango_const.h

const char * const DevStateName[] = { "ON", "OFF", "CLOSE", "OPEN", "INSERT", "EXTRACT", "MOVING", "STANDBY", "FAULT", "INIT", "RUNNING", "ALARM", "DISABLE", "UNKNOWN" };

stephane commented 10 years ago

So Tango needs to be fixed!