Tag: 编译器构造

灰度图像转换.img到.ras – 在Windows中的白色和蓝色的灰度等级?! C

我想将.img文件(512字节标题,512×512像素,每像素8位(值:0-255))转换为.ras文件。 为此,我在本文末尾得到了C代码。 我的测试图像(test.img)的输出应该是黑/白图像 – 所以只包含0或255的值。但问题是,当我在Windows中编译C代码(从底部)时,我的结果。 ras文件是白色还是亮蓝色?! 奇怪的是。 当我在Linux中编译C代码时,结果是完全黑/白?! 这怎么来的? 在两个系统中我使用了64位。 所以你可以尝试一下:1。用以下代码编译C代码:gcc -lm img2ras.c -o img2ras 2.通过控制台将.img转换为.ras:img2ras test.img test.ras 3.在gimp中观察.ras文件,XnView或PaintshopPro 你是否有任何线索如何在具有相同版本的gcc 4.8.1的不同操作系统上发生这种尴尬的结果? test.img: http : //www.file-upload.net/download-8629102/test.img.html img2ras.c /* this program accepts an input file (which comes from the image capturing board) and an output file, which must be specified on the command line. The output file […]

我是否需要明确包含共享库中使用的公共头文件(在包含路径文件夹中)?

我正在使用共享库,比如shr.so 这有一些头文件,比如shr_struct.h ,我需要在我的程序中使用的结构,比如shr_struct.h 。 我是否需要在include路径中保留shr_struct.h的副本, shr_struct.h在shr_struct.h中的shr_struct.h中声明结构类型的对象?

Flex不在多行注释上正确计算行数

我使用上面的正则表达式来识别Flex中的多行注释: [/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] { /* DO NOTHING */ } 但在我看来,flex / bison没有正确返回线路计数器。 例如: 输入: 1 ___bqmu7ftc 2 // _qXnFEgQL9Zsyn8Ohtx7zhToLK68xbu3XRrOvRi 3 /* “{ output 6 = <=W if u7 do nN)T!=$||JN,a9vR)7" 4 -758939 5 -31943.6165480 6 // "RND" 7 '_' 8 */ 9 [br _int] 输出: 1 TK_IDENT [___bqmu7ftc] 4 [ 4 TK_IDENT [br] 4 TK_IDENT [_int] […]

编译时,数组类型具有不完整的元素类型错误

在我们的课程中,我们将实现在bochs模拟器上构建的内核。 其中一个子任务是实现固定优先级调度。 以前我们的调度程序只有一个线程队列,但现在我想创建一个线程队列数组。 但我的数组不断得到一个编译错误“数组类型有不完整的元素类型”我发布了下面的一些代码,任何人都可以看到问题。 kernel.h当 … extern struct thread_queue ready_queue_table[MAX_SYS_PRIORITY]; … kernel.c … #include #include “threadqueue.h” … struct thread_queue ready_queue_table[MAX_SYS_PRIORITY]; … sysdefines.h … #define MAX_SYS_PRIORITY (5) … threadqueue.h … struct thread_queue { int head; /*!< The index to the head of the thread queue. Is -1 if queue is empty. */ int tail; /*!< The […]

多个进程或库副本之间的C字符串文字存储

当您运行特定程序或库的多个副本时,各种系统的行为是什么,字符串文字是在RAM中存储一次还是对于进程/库的每个副本存储一次? 如果它们存储在如下数组中,该怎么办? static const char *const foo[] = { “bar”, “baz”, “buz” }; static是否会改变内存存储的行为? 编辑:由于它可能是特定于平台的,因此Windows上的Microsoft编译器或Linux上的GCC(x86)上的行为是什么?

如何使用Turbo C ++编译器配置eclipse CDT

如何使用Turbo C ++编译器配置eclipse。

将指针传递给C中的指针

编译: #include void f(int ** v) { } int main() { int v[2][3]; f(v); return 0; } 失败了: g.cpp:13:8: error: cannot convert ‘int (*)[3]’ to ‘int**’ for argument ‘1’ to ‘void f(int**)’ 但是通过了以下更改: #include void f(int ** v) { } int main() { int * v[2]; f(v); return 0; } 在我看来,数组的更深层次必须在编译时解决,有人可以详细说明它吗?

MinGW编译器不需要函数声明吗?

我有这两个文件: // first.c int main(void) { putint(3); } 和 // second.c #include void putint(int n) { printf(“%d”,n); getchar(); } 当我在Win XP下运行gcc 4.6.1时: gcc first.c second.c -o program.exe 它没有问题,并写入3到stdout。 它在first.c中不需要putint声明。 这怎么可能? 这是标准行为吗? 我已经在MSVC 2008 Express上对此进行了测试,它只能按预期运行。 // first.c void putint(int); int main(void) { putint(3); } 解决了 ,谢谢提示,这些选项有助于显示警告: -Wimplicit -std = c99(MinGW 4.6默认使用gnu90 )

C ++无法建立对“父”对象的句柄引用 – 循环包含或未定义的类型错误

我希望有一个层次结构的类结构,其中一级控制器“父”类负责创建/指导一些“子”类。 父类应该能够引用它直接创建的每个子节点,并且每个子节点应该能够引用它的父节点(并且,假设这个子节点也不是更多类的父节点,只有它的父节点)。 这允许通过父级引用兄弟姐妹。 我发现这个范例在Java和C#等JIT编译语言中很有用,但是C ++提出了一个独特的问题…… 我第一次尝试实现这个范例如下: 父类TreeRoot.h #ifndef __CCPP_SCENE_H__ #define __CCPP_SCENE_H__ #include “ChildA.h” #include “ChildB.h” class TreeRoot : { private: ChildA* a; ChildB* b; public: //member getters ChildA* getA(); ChildB* getB(); }; #endif // __CCPP_SCENE_H__ Child class ChildA.h #ifndef CHILDA_H_ #define CHILDA_H_ #include “TreeRoot.h” class ChildA { private: TreeRoot* rootScene; public: ChildA(TreeRoot*); ~ChildA(void); TreeRoot* getRootScene(); […]

在MPI中,多进程scanf只接受一次输入并将垃圾值分配给其他?

我正在尝试使用scanf编写MPI代码,它将单独为所有进程输入输入,但只有一个进程从用户获取输入,而其他进程将垃圾值分配给该变量。 该计划如下 #include #include #include “mpi.h” #include int main(int argc, char* argv[]) { int i, size, rank; int arr; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); printf(“Enter the number\n”); scanf(“%d”,&i); printf(“%d\n”,i); MPI_Finalize(); exit(0); }