How can a variable of type char be assigned? I am looking for the Xtend equivalent of javas:
char c='?';
In Xtend the compiler reject all quotation marks like ' or " because they produce a String:
var char c='?';
^ Error: Incompatible types. Expected char or java.lang.Character but was java.lang.String
Xtext Version is 2.2
Since 2.4 you can write:
val char c = '?'
Currently you have to use '?'.charAt(0).
Related
If a double value of 8.13 is passed into json_real and dump the json i see that its printing 8.1300000000000008, Is there any way to get 8.13 or 8.13000000000000000 exactly in C?
double test = 8.13;
json_t* msgtest = json_object();
json_object_set_new(msgtest, "test", json_real(test));
char* msgStr;
msgStr = json_dumps(msgtest, 0);
You can use JSON_REAL_PRECISION, introduced in jansson 2.7.
Output all real numbers with at most n digits of precision. The valid
range for n is between 0 and 31 (inclusive), and other values result
in an undefined behavior.
By default, the precision is 17, to correctly and losslessly encode
all IEEE 754 double precision floating point numbers.
Consider the following program:
#include <jansson.h>
int main() {
double test = 8.13;
json_t* msgtest = json_object();
json_object_set_new(msgtest, "test", json_real(test));
printf("%s\n", json_dumps(msgtest, JSON_REAL_PRECISION(3)));
}
It prints
{"test": 8.13}
I want to add the mysql connection with the pcap loop which I am using in the code
MYSQL *con;
u_char *my_arguments = con;
pcap_loop(handle, total_packet_count, my_packet_handler, my_arguments);
but it is giving error
warning: initialization from incompatible pointer type
[-Wincompatible-pointer-types]
u_char *my_arguments = con;^~~
SO what should I do help is needed please
When I am directly putting value of con in pcap loop like pcap_loop(handle, total_packet_count, my_packet_handler, con); it is showing new error
Error is
passing argument 4 of ‘pcap_loop’ from incompatible pointer type
[-Wincompatible-pointer-types]
pcap_loop(handle, total_packet_count, my_packet_handler, con);
note: expected ‘u_char * {aka unsigned char *}’ but argument is of type ‘MYSQL * {aka struct st_mysql *}’
PCAP_API int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
but I want it to be pushed in pcap loop
The "user" argument to pcap_loop(), pcap_dispatch(), and the callback probably should have been defined to be a void *, as it's a pointer to some arbitrary data that the callback understands, but it was defined to be a u_char * instead.
So you should cast the MYSQL * to u_char *:
pcap_loop(handle, total_packet_count, my_packet_handler, (u_char *)con);
How do you fix the following problem converting from decimal to binary?
void tobinary(int bin) {
string binary = Convert.ToInt32(bin, 2);
}
These are the errors:
Error 2: Argument 2: cannot convert from 'int' to 'System.IFormatProvider' 42
Error 1: The best overloaded method match for 'System.Convert.ToInt32(object, System.IFormatProvider)' has some invalid arguments 42
see:
Decimal to binary conversion in c #
it should be:
void tobinary(int bin) {
string binary = Convert.ToString(bin, 2);}
I have the following function definition:
create or replace FUNCTION checkXML
(idx in number(19))
return number(19)
is
...
But when I compile it, am getting the following errors,
Error(2,16): PLS-00103: Encountered the symbol "(" when expecting one of the
following: := . ) , # % default character The symbol ":=" was substituted for
"(" to continue.
Error(3,15): PLS-00103: Encountered the symbol "(" when expecting one of the
following: . # % ; is authid as cluster order using external character
deterministic parallel_enable pipelined aggregate result_cache
Change the function declaraction to be
create or replace FUNCTION checkXML
(idx in number)
return number
PL/SQL doesn't accept length or precision specifiers on parameters or return types.
Share and enjoy.
How to correctly use std::map<int, std::map<POINTER, STRUCT>> in SWIG when target is C#.
From documentation, tried using
namespace std
{
%template(map_POINTER_STRUCT) map<POINTER, STRUCT>;
%template(map_int_map_POINTER_STRUCT) std::map<int, std::map<POINTER, STRUCT>>;
}
But SWIG still gives error Error: Syntax error in input(3).
The error is due to SWIG and older C++ compilers mistaking >> for the right-shift operator. Insert a space:
%template(map_int_map_POINTER_STRUCT) std::map<int, std::map<POINTER, STRUCT> >;
^
here