BMessage msg; msg.AddData("my_string", B_STRING_TYPE, "Hello, world!", strlen("Hello, world!"));
BMessage msg; int my_int = 42; msg.AddData("my_int", B_INT32_TYPE, &my_int, sizeof(my_int));In this example, we create an integer variable called my_int with the value 42, and then use AddData to add it to a BMessage with the key "my_int". The BMessage class is part of the BeOS/Haiku Application Kit library.