I encounter some strange behaviour when running this piece of code:
Code: Select all
/*
* Project.c
*************/
#include <stdio.h>
#include <string.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/types.h>
#include <exec/tasks.h>
#include <proto/exec.h>
#include <proto/wb.h>
#include <workbench/workbench.h>
#include <proto/dos.h>
#define ELSE_ERROR(Err) else IDOS->Printf("ERROR: Failed to %s\n", Err)
#define INFO(info) IDOS->Printf("INFO : %s\n", info)
int main(int argc, char *argv[])
{
// INFO("=== Start of Program ===");
struct Library *WorkbenchBase = IExec->OpenLibrary("workbench.library", 50L);
if (WorkbenchBase)
{
struct WorkbenchIFace *IWorkbench = (struct WorkbenchIFace *)IExec->GetInterface(WorkbenchBase, "main", 1L, TAG_DONE);
if (IWorkbench != NULL)
{
struct List *list = NULL;
if ((IWorkbench->WorkbenchControl(NULL, WBCTRLA_GetProgramList, &list, TAG_DONE)) == TRUE)
{
STRPTR ProgName;
struct Task *Task;
struct Node * node = IExec->GetHead(list);
INFO("=== Start of List ===");
while (node != NULL)
{
ProgName = (STRPTR)IDOS->FilePart(node->ln_Name);
IDOS->Printf("INFO : [ %08lx ]", node);
if ((Task = IExec->FindTask(ProgName)) != NULL)
{
IDOS->Printf(" -- [ %08lx ] | [ %3ld ]", Task, Task->tc_Node.ln_Pri);
}
else
{
IDOS->Printf(" ");
}
IDOS->Printf(" -- %s\n", ProgName);
node = IExec->GetSucc(node);
}
INFO("==== End of List ====");
if ((IWorkbench->WorkbenchControl(NULL, WBCTRLA_FreeProgramList, list, TAG_DONE)) == FALSE)
{
INFO("Free Programlist failed");
IDOS->Printf("Failer due to [ %ld ]\n", IDOS->IoErr());
}
}
ELSE_ERROR("Get ProgramList");
IExec->DropInterface((struct Interface *)IWorkbench);
}
ELSE_ERROR("Get Interface");
IExec->CloseLibrary(WorkbenchBase);
}
ELSE_ERROR("Open Library");
INFO("==== End of Program ====");
return 0;
}
Code: Select all
SWITCHES = -W \
-Werror \
-Wmissing-prototypes \
-Wsign-compare \
-Wundef \
-Wwrite-strings
DEBUG =
FILES = main.c
ProjecT.DEBUG : $(FILES)
gcc main.c -o ProjecT.DEBUG $(SWITCHES) $(DEBUG)
@echo "=== Done making DEBUG ================="
Well, the problem is that when even a small and minor change, like uncommenting the first line in main(), is applied to the source and compiled again, I get this compilation message:
Code: Select all
gcc main.c -o ProjecT.DEBUG -W -Werror -Wmissing-prototypes -Wsign-compare -Wundef -Wwrite-strings
ld: cannot open output file ProjecT.DEBUG: Text file busy
make: *** [ProjecT.DEBUG] Error 1
Could anyone please comment?
OldFart