gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > general programming questions

#55937 - sparda - Tue Oct 04, 2005 7:11 pm

I would like to know a few things because im curious as well as confused.

1. What is a "thread", or "threading" in a programming sense?

2. What in the world is a Raster, or Rastering?

3. And my last question ( although it should have gone in C programming section) Can i include ".c" files just as i include Heather files?

for example:

#include <my_main.c>
or #include "my_main.c"

or is it just for heather files???

if anyone can help me out, i'll greatly appreciate it. thanks
_________________
genius is 1% inspiration, 99% perspiration .

#55944 - poslundc - Tue Oct 04, 2005 8:30 pm

sparda wrote:
1. What is a "thread", or "threading" in a programming sense?


Threading is the act of sharing the processor among multiple tasks that are running "at the same time", which is to say they're not literally running at the same time, but that one task may be suspended (either voluntarily, such as in a cooperative multitasking system, or involuntarily by being interrupted by a preemptive multitasking system) so that another task may run on the processor.

Very few, if any, apps on the GBA are complicated enough to require a threading system.

Quote:
2. What in the world is a Raster, or Rastering?


A literal representation of image data on the screen. On the GBA, raster is often a shorthand for "raster effects", which refer to tricks to modify the display on a scanline-by-scanline basis (affecting the rasterized data, rather than the data in VRAM) to achieve various effects. Mode 7 is an example of this.

Quote:
3. And my last question ( although it should have gone in C programming section) Can i include ".c" files just as i include Heather files?


It's legal C syntax, but breaks the paradigm entirely.

C files should be compiled individually (although you can do them all at the same time by passing them all into a single command line instruction) and then linked together (which happens automatically if you do them all in a single instruction; otherwise just pass in the .o files a second time).

You should only ever #include header files, and they should mainly contain things like data structures, macro declarations, and extern variable references. Never declare your variables in them, and the only executable code (functions) they should ever have is if it's a macro or declared as inlined.

Dan.

#55946 - headspin - Tue Oct 04, 2005 8:40 pm

poslundc wrote:
You should only ever #include header files, and they should mainly contain things like data structures, macro declarations, and extern variable references. Never declare your variables in them, and the only executable code (functions) they should ever have is if it's a macro or declared as inlined.


At a minimum they should contain function prototypes of those defined in the associated c file.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#55976 - jun - Wed Oct 05, 2005 3:32 am

Quote:



3. And my last question ( although it should have gone in C programming section) Can i include ".c" files just as i include Heather files?

for example:

#include <my_main.c>
or #include "my_main.c"

or is it just for heather files???





a practical use for this is when programming using templates and you're compiler does not fully support the latest ANSI templates( have tested this with c++ compiler of mscv2005) however i have not tried with the latest gcc, but in my experiece, gcc outdoes ms compilers in templates at least.

you would then use the inclusion method which is simply including the .cpp files where template implemetation resides into the file where you iintend to use them,

// as such:
// myfile.cpp or myfile.h
#include "stacktemplate.cpp"

// use template here
// end of file

#55977 - sparda - Wed Oct 05, 2005 3:55 am

Now i understand, Thanks for clearing this up for me guys.
_________________
genius is 1% inspiration, 99% perspiration .