Vb set_syntax does strange things... maybe


In the constructor of my class i do some initializations for oid and syntax fields of Vb class objects.

for (int i=0; i<COOLING_ENTRY_NUM; i++) CoolingEntry[i].Valore = new Vb;

CoolingEntry[0].Valore->set_oid( “” );


When later I’ve to use this array I find that the Vb setted to sNMP_SYNTAX_INT32 are instead sNMP_SYNTAX_GAUGE32 with value 66.

I know that all the numbers are 32 bits and the only difference in code is between unsigned and signed long but I would like to understand if I’m doing something wrong or simply I’ve to manage all my switch case grouping all number together.



Hello Luca,

unfortunately you did not show the code where you set the value 66, so I have to guess.
The class Vb has (beside others) the following two set_value() functions:

   * Set the value with an int.
   * The syntax of the Vb will be set to SMI INT32.
  void set_value(const int i) { free_vb(); iv_vb_value = new SnmpInt32(i); };

   * Set the value with an unsigned int.
   * The syntax of the Vb will be set to SMI UINT32.
  void set_value(const unsigned int i)
    { free_vb(); iv_vb_value = new SnmpUInt32(i); };

If you set the 66 using an unsigned variable, the second function is called which sets the syntax to UINT32 which is the same as GAUGE32.

Kind regards,

Ok, now I understand

Thank you Jochen