unsigned

Struct operations in Javascript through Emscripten

与世无争的帅哥 提交于 2019-12-01 00:40:44
I am having quite a lot of problems with emscripten inter-operating between C and Javascript. More specifically, I am having trouble accessing a struct created in C in javascript, given that the pointer to the struct is passed into javascript as an external library . Take a look at the following code: C: #include <stdlib.h> #include <stdio.h> #include <inttypes.h> struct test_st; extern void read_struct(struct test_st *mys, int siz); struct test_st{ uint32_t my_number; uint8_t my_char_array[32]; }; int main(){ struct test_st *teststr = malloc(sizeof(struct test_st)); teststr->my_number = 500;

攻防世界--ReverseMe-120

时光总嘲笑我的痴心妄想 提交于 2019-11-30 23:56:46
测试文件: https://adworld.xctf.org.cn/media/task/attachments/a5c0e8322d9645468befabddfe0cb51d.exe 1.准备 获取信息 32位文件 2.IDA打开 1 int __cdecl main(int argc, const char **argv, const char **envp) 2 { 3 unsigned int v3; // edx 4 unsigned int v4; // ecx 5 __m128i v5; // xmm1 6 unsigned int v6; // esi 7 const __m128i *v7; // eax 8 __m128i v8; // xmm0 9 int v9; // eax 10 char v11; // [esp+0h] [ebp-CCh] 11 char v12; // [esp+1h] [ebp-CBh] 12 char v13; // [esp+64h] [ebp-68h] 13 char v14; // [esp+65h] [ebp-67h] 14 unsigned int v15; // [esp+C8h] [ebp-4h] 15 16 printf("please input your flah:"); 17 v11 = 0; 18

MYSQL结构修改

两盒软妹~` 提交于 2019-11-30 23:47:01
mysql改表结构主要是5大操作 ADD   添加字段 MODIFY 修改字段类型 CHANGE 修改字段名(也可以修改字段名) DROP   删除字段 RENAME 修改表名 ADD添加新字段:(新字段默认添加在所有字段末尾,可以设定位置) 语法结构为:   ALTER TABLE 库名.表名   ADD 列名 类型(范围) 约束条件   [ AFTER 字段名 | FRIST ] mysql> DESC f_fri_list; +---------------+-------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | type | enum('男','女') | NO | | NULL | | | fri_id | int(10) unsigned | NO | | NULL | | | fri_name | char(10) | NO | |

工作小结一

自古美人都是妖i 提交于 2019-11-30 23:40:43
目录 工作小结一 1.1 如何进行C矩阵运算 1.2 如何提升malloc和free的效率 1.3 C实现深林 1.4 C优雅的函数 工作小结一 1.1 如何进行C矩阵运算 很多时候我们使用 matlab 、 python 、 c++ 等进行矩阵操作,但是当进行实际操作的时候,我们得把这些语言使用 C 去实现。 实现起来有两种方式: [x] 一级指针 定义方式如下: typedef struct Matrix_t { unsigned int rows; unsigned int cols; void* data; //具体实现看个人需求 }Matrix; 新建和释放方式如下: //Matrix* matrix = (Matrix*)malloc(sizeof(Matrix));//返回返回加入,参数进入不需要 /*Example void CreatMatrix(Matrix* src) { ....; } Matrix* CreatMatrix() { return ...; } */ matrix->data = (void*)malloc(sizeof(void)*rows*cols); free(matrix->data); //free(matrix);//返回返回加入,参数进入不需要 遍历方式如下: for (size_t i=0;i<rows;i++) for

C/C++ use of int or unsigned int

别说谁变了你拦得住时间么 提交于 2019-11-30 22:20:01
问题 In a lot of code examples, source code, libraries etc. I see the use of int when as far as I can see, an unsigned int would make much more sense. One place I see this a lot is in for loops. See below example: for(int i = 0; i < length; i++) { // Do Stuff } Why on earth would you use an int rather than an unsigned int ? Is it just laziness - people can't be bothered with typing unsigned ? 回答1: Using unsigned can introduce programming errors that are hard to spot, and it's usually better to use

MISRA C:2004, error with bit shifting

情到浓时终转凉″ 提交于 2019-11-30 21:54:37
I'm using IAR Workbench compiler with MISRA C:2004 checking on. The fragment is: #define UNS_32 unsigned int UNS_32 arg = 3U; UNS_32 converted_arg = (UNS_32) arg; /* Error line --> */ UNS_32 irq_source = (UNS_32)(1U << converted_arg); The MISRA error is: Error[Pm136]: illegal explicit conversion from underlying MISRA type "unsigned char" to "unsigned int" (MISRA C 2004 rule 10.3) I don't see any unsigned char in any of the code above. The discussion at Why did Misra throw an error here? discusses multiplication which may have different promoting rules than left shifting. My understanding is

How to convert signed 32-bit int to unsigned 32-bit int?

自作多情 提交于 2019-11-30 20:07:26
This is what I have, currently. Is there any nicer way to do this? import struct def int32_to_uint32(i): return struct.unpack_from("I", struct.pack("i", i))[0] Not sure if it's "nicer" or not... import ctypes def int32_to_uint32(i): return ctypes.c_uint32(i).value using numpy for example: import numpy result = numpy.uint32( numpy.int32(myval) ) or even on arrays, arr = numpy.array(range(10)) result = numpy.uint32( numpy.int32(arr) ) 来源: https://stackoverflow.com/questions/16452232/how-to-convert-signed-32-bit-int-to-unsigned-32-bit-int

Struct operations in Javascript through Emscripten

强颜欢笑 提交于 2019-11-30 19:49:52
问题 I am having quite a lot of problems with emscripten inter-operating between C and Javascript. More specifically, I am having trouble accessing a struct created in C in javascript, given that the pointer to the struct is passed into javascript as an external library. Take a look at the following code: C: #include <stdlib.h> #include <stdio.h> #include <inttypes.h> struct test_st; extern void read_struct(struct test_st *mys, int siz); struct test_st{ uint32_t my_number; uint8_t my_char_array[32

Why is (18446744073709551615 == -1) true?

假装没事ソ 提交于 2019-11-30 17:48:25
When I was working on string::npos I noticed something and I couldn't find any explanation for it on the web. (string::npos == ULONG_MAX) and (string::npos == -1) are true. So I tried this: (18446744073709551615 == -1) which is also true. How can it be possible? Is it because of binary conversation? Evan Carroll 18,446,744,073,709,551,615 This number mentioned, 18,446,744,073,709,551,615 , is actually 2^64 − 1 . The important thing here is that 2^64-1 is essentially 0-based 2^64 . The first digit of an unsigned integer is 0 , not 1 . So if the maximum value is 1 , it has two possible values: 0

Why doesn't GCC produce a warning when assigning a signed literal to an unsigned type?

穿精又带淫゛_ 提交于 2019-11-30 17:31:00
Several questions on this website reveal pitfalls when mixing signed and unsigned types and most compilers seem to do a good job about generating warnings of this type. However, GCC doesn't seem to care when assigning a signed constant to an unsigned type! Consider the following program: /* foo.c */ #include <stdio.h> int main(void) { unsigned int x=20, y=-30; if (x > y) { printf("%d > %d\n", x, y); } else { printf("%d <= %d\n", x, y); } return 0; } Compilation with GCC 4.2.1 as below produces no output on the console: gcc -Werror -Wall -Wextra -pedantic foo.c -o foo The resulting executable