If it fails, hit it with a pipe

I am sure I have done this in the past and now again. It seems that I am mistaken again and the int on 64 bit systems is not 64, which is odd and not odd at once. I have no opinion, just seems odd. FYI sizeof is in "bytes" not bits and I do that conversion and expression in either form. It is usually easy to decipher in context which way a person is thinking, but I suppose it could get confusing when an int is 32 bytes and void * is 64 bytes. This means that I have mistaken INT issues for architecture implementation issues. A person who programs in C should at least be aware that architecture in pointer size and register size can make the code act oddly at times. If I am using an int and assuming it encompasses a void *, I would get the wrong result. I have seen long long used and that is even more scary in its implications. I can't say I have a single way I would deal with that, I suppose it depends on the circumstance.

printf("size_t is %d\n",(int)sizeof(size_t));
printf(" 8_t   is %d\n",(int)sizeof(uint8_t));
printf("16_t   is %d\n",(int)sizeof(uint16_t));
printf("32_t   is %d\n",(int)sizeof(uint32_t));
printf("64_t   is %d\n",(int)sizeof(uint64_t));
printf("int    is %d\n",(int)sizeof(int));
printf("uint   is %d\n",(int)sizeof(unsigned int));
printf("long   is %d\n",(int)sizeof(long int));
printf("long long is %d\n",(int)sizeof(long long int));
ISO C90 does not support this.
printf("void * is %d\n",(int)sizeof(void *));

This rates top of blog post. I was mutating things to create a program that teaches itself and develops a decision tree of what it decides and I discovered something VERY interesting. I should have been linking with "-ldl" when using the fault handling code and it was not until I tried to merge it with my new code which did not use SDL, that it became apparent something was screwy. There is apparently a function in SDL that is dladdr with a reasonable analogy of definition. It may be that somewhere deep in the includes there is something circular, but it is scary! I need to dig deeper into this to resolve the issue, but it just shows how difficult it can be to produce gospel code. I won't go on and on about dynamic linking as it is something that is too complex to even touch here.

I can't leave well enough alone. I decided I would display the lines in the code that generated a failure. In order to do that I create a pipe that opens from the shell command. I just started this little side adventure and the rest of it is just busy work to parse the data and find the file and get the line and decide how much code to show around the area of the failure. This helps in making this code familiar to me and by scrambling it up and manipulating it, I get the sense of how it operates. The essential code and the data types needed is here for example.

This might seem odd, but my ultimate intent is to let the program look at its own failures and determine what to do about it. I have set up automated methods to program a C program and compile it. Then it is run and the result is analyzed in the same ways that I check my code. I am extending the type of action where I solve a puzzle to present a valid puzzle. Thus, the code generates a program using the methods it knows and determines if it achieves its solution, and if not it programs some more. I am sure I have passed some milestone of loopiness now, because the code searches itself for interesting things to post to the internet :)

It can also have a log or running commentary of what it tried to solve its problem and after some time it would give up and ask for help. system("espeak 'help, me I am a noob and my code won't work!'") I need some automated procedure that tells the program to RTFM or Google a solution so I won't be bothered.

FILE *fp; int status; char path[PATH_MAX];
sprintf(sysres,"addr2line %p -f -e solver",bt[i]); fp = popen(sysres, "r"); if (fp == NULL){printf("Pipe failed\n");} while (fgets(path, PATH_MAX, fp) != NULL) printf("%s", path); status = pclose(fp); if (status == -1) {printf("Pipe close failed %d\n",1);}

Alice Infinity, did you post this?

    sz = backtrace(bt, 20);
    strings = backtrace_symbols(bt, sz);
 for (i=0; i < sz; i++) {
  if ( bt[i] < (void *)0x420000 && bt[i] > (void *)0x400000) {
  sprintf(syscom,"addr2line %p -f -e solver > temp.line",bt[i]);
  sprintf(sysres,"addr2line %p -f -e solver | grep -v sighandler",bt[i]);
  fp = popen(sysres, "r");
   if (fp == NULL){printf("Pipe failed\n");}
   while (fgets(path, PATH_MAX, fp) != NULL){
    if ( path[0] == '/' )
     {printf("File name %s",path);
      for (ic=0;ic<strlen(path);ic++){
      if (ic2==1)
printf("Line %d ",(int)ic3);}
      if( path[ic] == ':' ){ic2++;}
   status = pclose(fp);
   if (status == -1) {printf("Pipe close failed %d\n",1);}

So now I have decided that the program should be able to teach other programs how to program. In this way the knowledge is passed on from generations of code. If the program generator keeps track of what it did and excludes the mistakes, or recognizes the solutions for common mistakes, then it would increase the rate at which succeeding generations of the program progressed. In addition it could collaborate and all the code which has evolved would combine effort to solve a problem when a new issue was posed. In this way the mistakes would not be repeated, new solutions would continue to accumulate and those programs that were the most effective at teaching could also e selected for quality and thus the overall scale would improve. I suppose they could even have high school teachers and graduate teachers that specialized in the more advanced programming subjects. Now I am getting dizzy and I think I have been programming too long again. I call recess.( Maybe later)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_STRINGS 2

char *whatString[MAX_STRINGS];

int putThis(char *toWrite, FILE *fp) {

return (fwrite(toWrite,1,strlen(toWrite),fp));

int dumpStrings(){
int i;
char *memString;
for (i=0;i<MAX_STRINGS;i++)
return 0;

int makeMe(){
return(system("gcc -Wall HelloWorld.c -o HelloWorld"));
int makeStrings(){
int i;
char *memString;
char stringN[256];
sprintf(stringN,"int main(){return 0;}\n");
 for (i=0;i<MAX_STRINGS;i++)
/* sprintf(stringN,"\n");*/
return 0;

int main (int argc, char * argv[]){
FILE *fp;
return 0;

I really love that sighandler and I am shining it up each chance I get. It is so slick and I can just link it and add -ldl to the process. Sweet. Above is the HelloMe writing HelloWorld.c and compiling it as a framework for the decision tree. I had to have something that worked to start with, so I don't get confused. I have to extend sighandler to know what it is linked with by using the shell at run time. It is a bit sloppy, but I was in a hurry to see if the concept actually worked in practice.


Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen