3

I found this very helpful example about MenuLayers and it works very well. In this line it is said that the method was defined in another file.

showDetail(cell_index); // Defined in detailView.c

As i compile and run, everything get´s called correctly. But im wondering how the compiler knows when to include this file?

I can see no include instruction, so my idea was that all files in the src/ folder will automatically be included. But if that is so, in which order?

r-dent
  • 685
  • 8
  • 22
  • 1
    That has nothing to do with the *compiler* or preprocessor (which handles the `#include` directive), it's the *linker* which does the "magic": The compiler writes special data in the object file, saying that the name `showDetail` is an external symbol, and then when the linker takes all source file it looks for the symbol `showDetail` in the other object files and write the correct output to the executable file. – Some programmer dude Jan 28 '14 at 09:39
  • That pretty much answers my Question. Maybe you can post it as an answer? – r-dent Jan 28 '14 at 18:05

1 Answers1

3

Pebble SDK uses waf as its build tool. It is configured in the wscript file.

If you look at the wscript file of your Pebble project you will see the following lines:

def build(ctx):
    ctx.load('pebble_sdk')

    ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
                    target='pebble-app.elf')

This tells the compiler to compile and link together all the ".c" files in src/ and all of its sub-directories.

sarfata
  • 4,625
  • 4
  • 28
  • 36