- 浏览: 896633 次
- 性别:
- 来自: 太原
文章分类
- 全部博客 (198)
- Linux/Unix (38)
- TinyOS / NS-2 for『WSN』 (44)
- 思想的拼图 (5)
- 开源 OpenSource (2)
- Framework 开发框架 (0)
- Software Engineering 软件工程 (2)
- IT项目管理 (6)
- Networking 网络技术 (2)
- Java (6)
- C语言 ANSI C (22)
- .NET / C# (9)
- C++ (12)
- Web 语言 Html/Xml (5)
- Groovy on Grails (1)
- Algorithm 算法 (1)
- Database 数据库技术 (5)
- Tools (21)
- VM 虚拟机 (3)
- WSN (wireless sensor network) (2)
- Linux 命令专辑 (3)
- PHP (0)
- 办公软件 (3)
最新评论
-
cfczdws:
感谢楼主,查了半天终于发现居然是htmlentities()做 ...
htmlentities()函数把中文转成了乱码 -
decoxiaohan:
这本书的名字 有谁知道????~~~
OMNeT++中文用户手册(完全版) -
huonie:
怎么下载啊
OMNeT++中文用户手册(完全版) -
huonie:
没有内容啊
OMNeT++中文用户手册(完全版) -
kyx0413:
谢谢先 先看看
OMNeT++中文用户手册(完全版)
A very simple test program, no locking or other precautions:
This defines a screen structure (from /usr/include/SDL/SDL_video.h), a special sort of variable that holds all kinds of information about the window we will be drawing.
Then we initialize the video subsystem, and again we specify to quit graciously whenever the time should come.
Then we give the physical dimensions of the screen, the colour depth and the type of surface we're drawing. From the documentation in the SDL_video.h we know that this declaration defines a surface in system memory (as opposed to one in video memory).
To the terminal we print a message, and then we quit.
The Makefile was adapted to build a different executable:
Type make (it gives a warning about non-void functions, because I tend to forget the return(0) statement, see the end of this section) and run your program.
That was too fast!
Even on this slow machine, so we will tell the program to wait a bit, using the sleep function:
Now we can start using the proverbial "edit the Makefile" cliche, again change the file names. Preferable even make a new directory for each program that you are working on.
Now if you run make like this, it will not work, because the sleep function is not defined in any of the libraries we included up until now. It will go like this:
But never despair, we can depend on the man pages:
And from man 3 sleep:
So we have to include as it says, and our program will look like this:
If you run make now, all should go reasonably well:
Warnings do not stop a program from being compiled, errors do, so we will get an executable file out of this. To get rid of the warnings, add return(0) at the end of the program, so that main returns a value, and rerun make.
And if you run the program, it should stay on your screen a bit longer now, and output this in your terminal window:
原文
/* Program name: testscreen1.c */ /* SDL screen test */ /* Always needed for SDL programs: */ # include <SDL.h> /* For (at)exit: */ # include <stdlib.h> int main() { SDL_Surface *screen; if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE); if ( screen == NULL ) { fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError()); exit(1); } printf("Set window of 640x480 at %d bits per pixel mode\n", screen->format->BitsPerPixel); }
This defines a screen structure (from /usr/include/SDL/SDL_video.h), a special sort of variable that holds all kinds of information about the window we will be drawing.
Then we initialize the video subsystem, and again we specify to quit graciously whenever the time should come.
Then we give the physical dimensions of the screen, the colour depth and the type of surface we're drawing. From the documentation in the SDL_video.h we know that this declaration defines a surface in system memory (as opposed to one in video memory).
To the terminal we print a message, and then we quit.
The Makefile was adapted to build a different executable:
引用
[tille@octarine ~/C/SDL/screen] cat Makefile
CC = gcc -Wall
BIN = testscreen1
CFLAGS=`sdl-config --cflags`
LDFLAGS=`sdl-config --libs`
all: $(BIN)
$(BIN): testscreen1.o
$(CC) testscreen1.o \
-o $(BIN) $(LDFLAGS)
clean:
@rm -f *.o
@rm $(BIN)
CC = gcc -Wall
BIN = testscreen1
CFLAGS=`sdl-config --cflags`
LDFLAGS=`sdl-config --libs`
all: $(BIN)
$(BIN): testscreen1.o
$(CC) testscreen1.o \
-o $(BIN) $(LDFLAGS)
clean:
@rm -f *.o
@rm $(BIN)
Type make (it gives a warning about non-void functions, because I tend to forget the return(0) statement, see the end of this section) and run your program.
That was too fast!
Even on this slow machine, so we will tell the program to wait a bit, using the sleep function:
/* Program name: testscreen2.c */ /* SDL screen test 2 */ /* Always needed with SDL: */ # include <SDL.h> /* For general functions: */ # include <stdlib.h> int main() { SDL_Surface *screen; if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE); if ( screen == NULL ) { fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError()); exit(1); } printf("Set window of 640x480 at %d bits per pixel mode\n", screen->format->BitsPerPixel); /* Show the window a bit longer: */ sleep(5); printf("Quitting SDL.\n"); }
Now we can start using the proverbial "edit the Makefile" cliche, again change the file names. Preferable even make a new directory for each program that you are working on.
Now if you run make like this, it will not work, because the sleep function is not defined in any of the libraries we included up until now. It will go like this:
引用
[tille@octarine ~/C/SDL/screen/test2] make
gcc -Wall `sdl-config --cflags` -c -o testscreen2.o testscreen2.c
testscreen2.c: In function `main':
testscreen2.c:23: warning: implicit declaration of function `sleep'
testscreen2.c:26: warning: control reaches end of non-void function
gcc -Wall testscreen2.o \
-o testscreen2 `sdl-config --libs`
gcc -Wall `sdl-config --cflags` -c -o testscreen2.o testscreen2.c
testscreen2.c: In function `main':
testscreen2.c:23: warning: implicit declaration of function `sleep'
testscreen2.c:26: warning: control reaches end of non-void function
gcc -Wall testscreen2.o \
-o testscreen2 `sdl-config --libs`
But never despair, we can depend on the man pages:
引用
[tille@octarine ~/C/SDL/screen/test2] apropos sleep
Tcl_Sleep (3) - delay execution for a given number of milliseconds
Tcl_Sleep [Sleep] (3) - delay execution for a given number of milliseconds
apmsleep (1) - go into suspend or standby mode and wake-up later
nanosleep (2) - pause execution for a specified time
sleep (1) - delay for a specified amount of time
sleep (3) - Sleep for the specified number of seconds
usleep (1) - sleep some number of microseconds
usleep (3) - suspend execution for microsecond intervals
Tcl_Sleep (3) - delay execution for a given number of milliseconds
Tcl_Sleep [Sleep] (3) - delay execution for a given number of milliseconds
apmsleep (1) - go into suspend or standby mode and wake-up later
nanosleep (2) - pause execution for a specified time
sleep (1) - delay for a specified amount of time
sleep (3) - Sleep for the specified number of seconds
usleep (1) - sleep some number of microseconds
usleep (3) - suspend execution for microsecond intervals
And from man 3 sleep:
引用
SLEEP(3) Linux Programmer's Manual SLEEP(3)
NAME
sleep - Sleep for the specified number of seconds
SYNOPSIS
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
DESCRIPTION
sleep() makes the current process sleep until seconds seconds have
elapsed or a signal arrives which is not ignored.
RETURN VALUE
Zero if the requested time has elapsed, or the number of seconds left
to sleep.
NAME
sleep - Sleep for the specified number of seconds
SYNOPSIS
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
DESCRIPTION
sleep() makes the current process sleep until seconds seconds have
elapsed or a signal arrives which is not ignored.
RETURN VALUE
Zero if the requested time has elapsed, or the number of seconds left
to sleep.
So we have to include as it says, and our program will look like this:
/* Program name: testscreen2.c */ /* SDL screen test 2 */ /* Always needed for SDL programs: */ # include <SDL.h> /* For atexit: */ # include <stdlib.h> /* For the sleep function: */ # include <unistd.h> int main() { SDL_Surface *screen; if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE); if ( screen == NULL ) { fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError()); exit(1); } printf("Set window of 640x480 at %d bits per pixel mode\n", screen->format->BitsPerPixel); sleep(5); printf("Quitting SDL.\n"); }
If you run make now, all should go reasonably well:
引用
[tille@octarine ~/C/SDL/screen/test2] make clean
[tille@octarine ~/C/SDL/screen/test2] make
gcc -Wall `sdl-config --cflags` -c -o testscreen2.o testscreen2.c
testscreen2.c: In function `main':
testscreen2.c:34: warning: control reaches end of non-void function
gcc -Wall testscreen2.o \
-o testscreen2 `sdl-config --libs`
[tille@octarine ~/C/SDL/screen/test2] make
gcc -Wall `sdl-config --cflags` -c -o testscreen2.o testscreen2.c
testscreen2.c: In function `main':
testscreen2.c:34: warning: control reaches end of non-void function
gcc -Wall testscreen2.o \
-o testscreen2 `sdl-config --libs`
Warnings do not stop a program from being compiled, errors do, so we will get an executable file out of this. To get rid of the warnings, add return(0) at the end of the program, so that main returns a value, and rerun make.
And if you run the program, it should stay on your screen a bit longer now, and output this in your terminal window:
引用
[tille@octarine ~/C/SDL/screen/test2] ls
Makefile testscreen2* testscreen2.c testscreen2.o
[tille@octarine ~/C/SDL/screen/test2] ./testscreen2
Set window of 640x480 at 16 bits per pixel mode
Quitting SDL.
Makefile testscreen2* testscreen2.c testscreen2.o
[tille@octarine ~/C/SDL/screen/test2] ./testscreen2
Set window of 640x480 at 16 bits per pixel mode
Quitting SDL.
原文
发表评论
-
ksh 使用手记
2009-12-03 20:52 18921. 实现像bash那样上下方向键显示^[[A,^[[B,不能 ... -
Linux建立本地cvs服务器
2009-08-14 22:25 1590在RH Linux上快速建立本地CVS服务器的小指南 前提, ... -
如何在 Linux 中执行命令?
2009-08-12 21:01 24181、怎样在后台执行命令 ... -
linux查看命令/文件所在路径的命令及修改
2009-08-12 21:01 36173whereis 用来查看一个命令或者文件所在的绝对路径,而 w ... -
我的 emacs 配置文件
2009-08-11 18:29 3582; Set up nesC syntax highligh ... -
emacs的缩进和自动添加新行
2009-07-27 22:22 6931emacs很强大,但是强大是以复杂的配置为前提的!没有配置好的 ... -
linux share文件
2009-07-27 20:57 2208安装好samba并在share folder中设置好想要共享的 ... -
Emacs学习笔记
2009-07-24 23:09 18071. 如何安装el文件 A:单个文件直接放入 ... -
Ubuntu中emacs23 的字体设置和emacs初始窗口位置的小经验
2009-07-24 19:09 7801Debian users, if your emacs sta ... -
scim 智能拼音消失的恢复办法
2009-07-06 19:48 1519完全删掉~/.scim后重启scim -
Linux 字符操作指令
2009-07-03 01:19 1285awk awk 用来从文本文件中提取字段。缺省地,字段分割符 ... -
Shell编程学习摘录十三--shell函数
2009-07-02 01:16 4147shell允许将一组命令集 ... -
Linux Shell脚本编写详解
2009-07-01 23:56 58591. Linux 脚本编写基础 1.1 语法基本介绍 1 ... -
Grep用法
2009-06-25 23:40 24751. grep简介 grep (global search ... -
ubuntu不能识别U盘的问题
2009-06-19 01:57 21183ubuntu插入u盘后,系统没 ... -
linux编程环境配置
2009-06-16 21:29 1077Gedit 1. 在Edit->Perferen ... -
Ubuntu英文版中显中文
2009-06-16 00:13 2545添加中文语言包 方法1. 在system->找到 ... -
linux之less/more命令
2009-06-11 19:46 4027名称:less 使用权限:所有使用者 使用方式:les ... -
Ubuntu 修改默认启动项
2009-06-05 16:22 1875sudo cp /boot/grub/menu.lst /bo ... -
Emacs 显示行号
2009-04-11 21:52 4567显示行号 把linum.el放到加载路径~/.emacs.d ...
相关推荐
implicit declaration of function(解决方案).md
默认编译后,再回头编译vlc开源库,发现:lua/demux.c:55:13: 错误:implicit declaration of function ‘luaL_checkint’; did you mean ‘luaL_checkany’ 经过查找后发现,此gcc中宏定义没有生效,可能加载顺序出...
在数字系统设计中,IP( Intellectual Property)核是可重用的硬件模块,它们提供了特定的功能,如计数器、接口控制器、数字信号处理单元等。"Avalon总线下的PWM IP Core"是一个专为Avalon总线设计的脉宽调制(PWM)...
智能科学专业本科生学习智能技术课程的参考书,计算机视觉方向
fs/yaffs2/yaffs_vfs.c:530: error: implicit declaration of function 'truncate_setsize' fs/yaffs2/yaffs_vfs.c: At top level: fs/yaffs2/yaffs_vfs.c:876: warning: initialization from incompatible pointer ...
fs/yaffs2/yaffs_vfs.c:2383:2: error: implicit declaration of function 'get_sb_bdev' fs/yaffs2/yaffs_vfs.c: At top level: fs/yaffs2/yaffs_vfs.c:2390:2: error: unknown field 'get_sb' specified in ...
隐含混合条件受限玻尔兹曼机(Implicit Mixtures of Conditional Restricted Boltzmann Machines, 简称imCRBM)是一种先进的深度学习模型,主要用于处理实值数据(real-value data)。在传统机器学习中,受限...
模板方法模式是面向对象设计中的一种经典模式,它在C++编程中有着广泛的应用。该模式主要用于定义一个算法的框架,允许子类在不改变算法整体结构的情况下,对算法的某些特定步骤进行重定义。这种模式是基于继承的...
system/vold/cryptfs.c:1031:3: error: implicit declaration of function 'is_ice_enabled' [-Werror=implicit-function-declaration] if (is_ice_enabled()) ^ 下载资源后把相应目录下文件替换即可。 详情请参阅...
Extension of The Implicit Curve-Fitting Method for Fast Calculation of Thermodynamic Properties to Subcooled Refrigerant,丁国良,吴志刚,Calculations of refrigerant thermal properties are desired to ...
本文提出的方法利用广义径向基函数插值(Generalized Radial Basis Function Interpolant)作为核心工具,能够有效地处理复杂的地质结构。 #### 三、地质规则约束 为了更好地控制地质趋势并确保建模结果符合实际...
新增行#include <linux> 这有助于解决以下问题: error: implicit declaration of function 'signal_pending'; did you mean 'timer_pending'? [-Werror=implicit-function-declaration] 并更改行: wait_queue_t ...
对原始版本进行了两项修订: 强制使用RS-485模式修复了以下编译错误: xr_usb_serial_common.c: In function ‘xr_usb_serial_init’:xr_usb_serial_common.c:1565:18: error: implicit declaration of function ...
在Ubuntu 14.04中安装VMware Tools的时候,可能会出现安装不上的问题 ,原因是此工具自身的问题。...error: implicit declaration of function ‘smp_mb__before_clear_bit’ 附件是我经过修改后的,可安装成功。
sh a 364 suid.c: In function 'main': suid.c:3: warning: incompatible implicit declaration of built-in function 'execl' sh-3.1# id uid=0(root) gid=0(root)
# FMDB with SQLCipherpod 'FMDB/SQLCipher'end然后在终端cd到当前目录,接着运行pod install,此时编译工程会出现"Implicit declaration of function '...' is invalid in C99"的错误.解决方案:在FMDatabase.m 文件...
在本文“基于反向传播的PUDLE内隐词典学习加速_PUDLE Implicit Acceleration of Dictionary Learning by Backpropagation”中,作者Bahareh Tolooshams和Demba Ba探讨了利用反向传播加速词典学习(Dictionary ...
### 隐式建模在窄脉型矿体中的应用 #### 核心知识点解析 本文探讨了基于布尔组合约束的窄脉型矿体隐式建模方法。该方法通过构造挂壁和脚壁表面的隐式函数,并利用布尔组合约束形成组合隐式函数来表示完整的矿体...
当编译程序发现程序中某个地方有疑问,可能有问题时就会给出一个警告信息。警告信息可能意味着程序中隐含的...显示:warning: implicit declaration of function ‘Example()’。 警告原因: 在你的.c文件中调用了函数
Policy for [Groups] /Channel/Application not satisfied: Failed to reach implicit threshold of 1 sub-policies, required 1 remaining 错误原因: The most common reasons are: The identit