Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unimportant newbie request: start to finish with vga.h?

3 views
Skip to first unread message

milkfilk

unread,
Feb 6, 2003, 12:23:40 AM2/6/03
to
This is a curiosity thing. I've always seen C/C++ functions in the
man pages but I don't know what people actually use them for. I did a
`man vga_getcolors' and saw this:

SYNOPSIS
#include <vga.h>

int vga_getxdim(void);
int vga_getydim(void);
int vga_getcolors(void);


How would you actually use this? Like, if you wanted to use that
function vga_getxdim()? I know nothing about C, but I'm just curious.

I tried creating this:

---vga.c----------------

#include <iostream>
#include <vga.h>

int main()
{
int x=0;
int x = vga_getxdim(void);
std::cout << x + "\n";
return 0;
}


And then tried compiling with `g++
-I/usr/src/linux-2.4.18-14/drivers/video vga.c -o vga' but got a ton
of errors.

Can anyone post their source and compile command for a curious person?

Eric Moors

unread,
Feb 6, 2003, 6:47:51 AM2/6/03
to

cat > vgs.c << EOF
#include <stdio.h>
#include <vga.h>

int main()
{
int x;

x = vga_getxdim();
fprintf(stderr, "x = %d\n", x);
return 0;
}
EOF
gcc -lvga vgs.c -o vgs

Godwin Stewart

unread,
Feb 6, 2003, 6:55:15 AM2/6/03
to
milkfilk wrote:

> I tried creating this:
>
> ---vga.c----------------
>
> #include <iostream>
> #include <vga.h>
>
> int main()
> {
> int x=0;
> int x = vga_getxdim(void);
> std::cout << x + "\n";
> return 0;
> }
>
>
> And then tried compiling with `g++

1) You're declaring your variable "x" twice. Once is enough.

2) vga_getxdim(void) is the function declaration in which the (void) tells
us that it takes no parameters. In actual use, you therefore put nothing
between the parentheses: int x = vga_getxdim();

3) std::cout is a C++ construct but your source file is vga.c, and the
compiler will therefore expect C syntax, not C++. Rename it to vga.cpp and
recompile.

Alternatively, just do it in C:

#include <stdio.h>
#include <vga.h>

int main() {

printf("%d\n",vga_getxdim());
return 0;

}

--
G. Stewart -- gstewart at gstewart dot homeunix dot net
gstewart at spamcop dot net
Registered Linux user #284683

GnuPG key : BA3D01C6 (pgp.mit.edu)
Fingerprint: C3DF C686 6572 6E59 E3E4 0F40 2B9A 2218 BA3D 01C6
---------------------------------------------------------------
In the 60's people took acid to make the world weird.
Now the world is weird and people take Prozac to make
it normal.

milkfilk

unread,
Feb 6, 2003, 4:20:57 PM2/6/03
to
Thank you both for your responses. Very informative. Very appreciated.

:)


Godwin Stewart <gstewar...@remove.spamcop.net> wrote in message news:<3e424c8c$0$99306$45be...@newscene.com>...

0 new messages