A function that refuses to run anywhere else but main()

Hi. I have some code, that for some reason, I could not post it here in this post. Here's the address for it:

#if 0 shc Version 4.0.1, Generic Shell Script Compiler GNU GPL Version 3 Md - Pastebin.com

First off, I used "shc" to convert the code from shell script to C.
And The problem is, I cannot call

menu()

from anywhere but,

main()

The error code I get while trying to call this function is this:

./test22 terminated by signal SIGSEGV (Address boundary error)

I want to call it from within a case statement, like this:

case 100: // alt-d
     menu();
     break;
 

I know, that it is a big "NO NO" to use code that is generated by a source code converter, but, i'd rather not use the shell script in my code, just standard C code. So, that is my reasoning for that. Maybe that's the problem right there?

I hope i'm being verbose enough in this post.

Thanks for your time. Any help is appreciated.

Source code converters are OK, in and on themselves, but the problem begins when you try to edit the generated code. Code created by a generator is usually understandable only to the compiler - most likely even the generator is confused reading what it has produced. You don't create an assembler listing from compiled code and change that in assembler either (at least not as long hell is not overbooked and you are sentenced to doing this for your sins instead).

Let us take a step back: what is the reason you don't want to use a shell script? Maybe there is a way to solve this problem without using this abomination in what C was never intended to look like.

I hope this helps.

bakunin

I'd rather keep the code neat and tidy, so to speak. Using a shell script in the code is problematic.. for me. It's just ugly, IMO.

Thanks for the quick response.

OK, i can understand that. But why would you want to incorporate a shell script (or its C equivalent) into a C program in first place? What is the script supposed to do that the program can't do? Sorry, but i am confused.

bakunin

Simply because I can't write the code on my own... The shell script does everything that I need it to do, and saves me time by not having to write the code. I'm still a newb at C. :slight_smile:

If you have a working shell script that you think is ugly, why don't you show us that ugly shell code. Maybe we can help you make it pretty or, at least, less ugly. :o

Actually, i'd prefer to use it in its C format, first. If I can't do that, then i'll fall back to using the shell script. Thank you for the offer, though. It's appreciated.