c++ - How to pass a string value to K object in kdb+ -


these days written c++ interface called kdb+. in cpp file, define function follows:

 enter extern "c" k printinfo(k firstname, k secondname, k age)  {     if (firstname->t != -ks || secondname->t != -ks || age->t != -kj) {       printf("invalid params\n");       return krr("invalid params");    }    printf("firstname:%s\tsecondname:%s\tage:%ld", firstname->s, secondname->s, age->j);   return (k)0;  } 

after compiled dll, write q script file call it. code followed:

/ dll mymoving load functions , assign named variables / 2: used loading / 3 @ end specifies number of arguments printinfo:`myprint 2:(`printinfo;3) printinfo["yunfeng";"zhou";23] / printinfo[`yunfeng;`zhou;23] 

however, did not work. tried google , kx web side solve problem, did in vain.

your code should work fine if pass names symbols. if want allow character vectors, should allow firstname->t == 10 , same secondname when check argument types. furthermore, cannot use ->s access character vector data. need use ->n find number of characters , kc() pointer first character. note character vectors (unlike symbols) not null-terminated, cannot use c functions expect pointers null-terminated strings on pointers returned kc().


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -