小编Tho*_*s O的帖子

不知怎的,我违反了一个定义规则

我收到链接器的错误,例如:

osd.o(.ndata+0x514):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\osd.c: multiple definition of `video_buff_vis_num'
main.o(.ndata+0x0):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\main.c: first defined here
osd.o(.ndata+0x515):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\osd.c: multiple definition of `video_buff_draw_num'
main.o(.ndata+0x1):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\main.c: first defined here
osd.o(.ndata+0x516):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\osd.c: multiple definition of `vid_format'
main.o(.ndata+0x2):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\main.c: first defined here
osd.o(.ndata+0x518):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\osd.c: multiple definition of `vid_line'
main.o(.ndata+0x4):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\main.c: first defined here
Run Code Online (Sandbox Code Playgroud)

这让我感到烦恼,因为在源代码中,我已经包含了这些定义可能来自唯一地方的警卫.

#ifndef OSD_H …
Run Code Online (Sandbox Code Playgroud)

linker gcc

0
推荐指数
1
解决办法
391
查看次数

C中的函数指针

以下代码(函数原型):

void parse_ini(FSFILE *fp, void(*secFunc)(char*), void(*varFunc)(char*, char*));
Run Code Online (Sandbox Code Playgroud)

编译时出现错误:

util\setup.c:38: error: syntax error before '*' token
util\setup.c:38: error: 'parse_ini' declared as function returning a function
util\setup.c:38: error: syntax error before 'void'
util\setup.c:50: error: syntax error before '*' token
Run Code Online (Sandbox Code Playgroud)

是什么造成的?使用MPLAB C30,这是用于PIC24F/dsPIC 16位微控制器的GCC v3.23版本.

c gcc function-pointers

0
推荐指数
1
解决办法
905
查看次数

C中的指针以及如何将局部变量作为指针传递

我仍然是C的菜鸟.我经常使用它,但通常不使用C的指针功能.我要做的是将指针传递给函数内局部空间中已经存在的结构.我有这个代码:

struct WorldCamera p_viewer;
struct Point3D_LLA p_subj;
struct Point2D_CalcRes p_res;
p_viewer.hfov = 25;
p_viewer.vfov = 25;
p_viewer.p.lat = 10.0f;
p_viewer.p.lon = 10.0f;
p_viewer.p.alt = 100.0f;
p_subj.lat = 9.98f;
p_subj.lon = 10.0f;
p_subj.alt = 100.0f;
// Do something interesting here.
compute_3d_transform(&p_viewer, &p_subj, &p_res, 10000.0f);
// Do something interesting here.
Run Code Online (Sandbox Code Playgroud)

compute_3d_transform的原型是这样的:

void compute_3d_transform(struct WorldCamera *p_viewer, struct Point3D_LLA *p_subj, struct Point2D_CalcRes *res, float cliph);
Run Code Online (Sandbox Code Playgroud)

我想知道我是否做对了.我正在一个小型微控制器上编程,我认为它没有太大的内存保护.破坏一块内存可能会导致将来出现奇怪的错误,这些错误很难调试.我试图避免使用malloc/calloc函数,因为这些需要专用堆.

c

0
推荐指数
1
解决办法
2223
查看次数

什么是sprintf浮动的正确方法?

我正在尝试使用以下代码printf/sprintf浮点数:

sprintf(buff, "FPS: %d\n%.4f N %.4f E\nAl: %.1fm Rl: %.1f\n", fps, p_viewer.p.lat, p_viewer.p.lon, p_viewer.p.alt, p_viewer.roll);
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,我会收到这些警告:

gfx_game_engine.c:300: warning: format '%.4f' expects type 'double', but argument 4 has type 'float'
gfx_game_engine.c:300: warning: format '%.4f' expects type 'double', but argument 5 has type 'float'
gfx_game_engine.c:300: warning: format '%.1f' expects type 'double', but argument 6 has type 'float'
gfx_game_engine.c:300: warning: format '%.1f' expects type 'double', but argument 7 has type 'float'
Run Code Online (Sandbox Code Playgroud)

什么是sprintf浮动的正确方法?是否有特殊的格式字符?我觉得编译器可能会以某种方式转换类型,这可能会导致它减慢速度.

我正在使用dsPIC33FJ128GP802微控制器并使用MPLAB C30进行编译,MPLAB C30是GCC v3.23的变体.

c floating-point printf

0
推荐指数
1
解决办法
4746
查看次数

Delphi - 如何移动控件并刷新它

对于Delphi中的编程练习,我希望一次在屏幕上滚动一个像素,并在每次移动时重新绘制它,因此看起来它实际上正在移动.目前Delphi只是在开始和结束时绘制它,所以它并不顺畅.我尝试了重绘和刷新,但都没有奏效.我也尝试让它变得可见和不可见,看看它是否有用,但没有运气.

image1.Visible := true;
for i := 0 to 50 do
begin
   image1.Visible := false;
   image1.Left := image1.Left + 1;
   image1.Repaint(); // this doesn't work...
   for j := 0 to 1000000 do
   begin
      k := i + j; // do nothing code
   end; 
   image1.Visible := true;
end;
Run Code Online (Sandbox Code Playgroud)

有谁知道我错过了什么?谢谢.

delphi

0
推荐指数
1
解决办法
1336
查看次数

固定点乘以/除以15.16的数字

我正在寻找一种算法来乘以和除以15.16的固定点数.

我已经有加法和减法.那些很简单 - 简单的32位加法和减法.通过乘法和除法,我还可以添加许多三角函数和指数/日志函数.而且我认为我可以处理多次,因为我的库有一个互惠函数,我可以用它来实现除法:a * (1/b) = a / b.但是32位乘法不起作用,因为它忽略了小数点.

我正在研究一个16位微控制器,所以我想避免超过32位乘法,这在我的处理器上需要大约4个周期.但这并不重要,我只是想替换浮点数学.

我听说我需要移动或旋转结果,但我不确定这将如何帮助或具体如何改变它.任何建议或帮助表示赞赏!

fixed-point

0
推荐指数
1
解决办法
6082
查看次数