View unanswered posts | View active topics It is currently Sun Apr 20, 2014 10:35 pm






Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
How to tell if a file is included 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: How to tell if a file is included
ok,ok, thank you, don't worry , I still don't understand how to define what how where by which, I'm too old for this kind of rock'n roll.

Don't try to teach me, it's not worth while - I won't get how to do it anyway.

Maybe the developers will produce a linker one day and some basic libraries and headerfiles instead of all those currently hidden background pragma and whatever stuff, and all will be fine :P

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Mon Sep 22, 2008 12:25 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: How to tell if a file is included
Ford Prefect wrote:
ok,ok, thank you, don't worry , I still don't understand how to define what how where by which, I'm too old for this kind of rock'n roll.

Don't try to teach me, it's not worth while - I won't get how to do it anyway.

Maybe the developers will produce a linker one day and some basic libraries and headerfiles instead of all those currently hidden background pragma and whatever stuff, and all will be fine :P


As long as you have your towel, you'll be fine.

:wink:

_________________
Jeff McBride
Benson Robotics Club


Mon Sep 22, 2008 12:34 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: How to tell if a file is included
Quote:
I'm sorry but now you've lost me. What are you trying to do in RobotC that isn't working the way you expect? Can you give us a concrete example? The only truely weird thing about RobotC is that every program has one source file which may or may not have include files. In standard C a program is usually compiled from multiple source files each of which may or may not have include files. This is an unfortunate but understandable limitation.

This is a byproduct of one of the early design decisions for ROBOTC. It also happens to be the way that Interactive C works; many of the concepts behind ROBOTC were based on some of the groundbreaking concepts developed for IC.

Sytems designed for commercial development tend to have "projects" or "make files" that among other things contain lists of source files that make up a project. With ROBOTC the typical project is a single source file. So we looked at "How Can we simplify the user experience when the typical project is a single file?". This led to eliminatin of "makefile" concept, elimination of linker -- include the functionality in the compiler, etc. It made for easier sharing of programs -- simply transfer a single file rather than a makefile and hopefully all the constituent source files.

For larger projects, you can use multiple "#include" statements. Not as elegant as a larger system, but still workable.


Mon Sep 22, 2008 6:49 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: How to tell if a file is included
Robot C is based on Interactive C?
Did YOU write the programming language for the Rug Warrier :?:

This was a big leap for robot programmers - 15 years ago?

but nowadays, the platforms became larger and more powerful, the claims have risen, the horizons broaded, the programming language must grow with his duties, and finally no one is forbidden to learn from earlier mistakes...
maybe some of earlier decisions have to be reconsidered.

A linker and a makefile could be fine today ;)

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Mon Sep 22, 2008 7:08 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: How to tell if a file is included
Dick Swan wrote:
Quote:
... It made for easier sharing of programs -- simply transfer a single file rather than a makefile and hopefully all the constituent source files.

For larger projects, you can use multiple "#include" statements. Not as elegant as a larger system, but still workable.


Hi Dick,

I don't have a problem with the "single source file + includes" model. However, the #ifndef FOO statements at the begining of the RobotC include files do not work because the compiler is simply refusing to open the file a second time. So, instead of harmlessly skipping the redundant include it is causing compilation errors. It is possible to work around the problem by putting the #ifndefs around the #includes instead of inside the include files themselves but it is inelegant and puts the burden on the user (programmer) instead of on the author (library writer).

It would be nice if the compiler treated the redundant includes as warnings instead. "Ignoring file FOO as it has already been included earlier" or some such thing.

Jeff

_________________
Jeff McBride
Benson Robotics Club


Mon Sep 22, 2008 7:17 pm
Profile
Expert
User avatar

Joined: Sat Sep 20, 2008 12:16 pm
Posts: 106
Location: Curently fighting aliens on P3X-828
Post Re: How to tell if a file is included
I myself am ok with one source file. But other people might want to use a makefile.

P.S. Don't let them. I doubt that the NXT has the required space for the projects that they intend to make.

_________________
:downloading:
Sorry, your program could not be downloaded. Please reboot your computer.
FTC Team #2959 Team Smash Bros CLICK HERE.(or click www)
Quote:
What the world needs is more geniuses with humility, there are so few of us left.

Agreed


Mon Sep 22, 2008 7:18 pm
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: How to tell if a file is included
I DO want only 1 source file.
But I also like to have some libraries and header files.
Today all libraries are included, hidden, inside the compiler (math.lib, sort of stdio or a graph.lib, ...) - why not write them as extra files, include them to the main file and other self written headers and libs, and link them and make them executable by makefile?
where is the difference?
at least the transparency and the flexibility are growing.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Mon Sep 22, 2008 7:33 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: How to tell if a file is included
Ford Prefect wrote:
Robot C is based on Interactive C?
Did YOU write the programming language for the Rug Warrier :?:

This was a big leap for robot programmers - 15 years ago?

but nowadays, the platforms became larger and more powerful, the claims have risen, the horizons broaded, the programming language must grow with his duties, and finally no one is forbidden to learn from earlier mistakes...
maybe some of earlier decisions have to be reconsidered.

A linker and a makefile could be fine today ;)

ROBOTC is not based on IC. BUt I did look at some of the design principles behind IC for those that IMHO made good sense.

If you want to write programs that have 10s of thousands of lines of code, then ROBOTC is not the best choice. But the vast majority of end user applications are in the order of 100 line of user written code. ROBOTC is a great solution for this.

When you can simply recompile everything in a couple of seconds, you may not need the complexity of a linker.

The ROBOTC design team believes the paradigm of one project == one file is very appropriate to the vast majority of ROBOTC users.

Of course, ROBOTC works pretty good for power users as well. And features have been added for this demographic as well. Like the recent "__FILE__"" and "__MAIN__" capabilities; and the "find in all files" command. And the ability to select any souce file -- both user and system #include files -- from the VIEW menu when in "Advanced" or "Super User" menu.


Mon Sep 22, 2008 10:50 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: How to tell if a file is included
hello,
thx for your reply.
ok, I understood, you won't change the current neither-linker-nor-makefile-concept never.

So I have to reconsider my decision, that __FILE__ and __MAIN__ won't be a solution for my program architecture: I came to a point where I need double an crosswise file references.
So it can't avoid to ask you
- if you please may have a look at my 2 examples of 3 corrsponding files each that I posted above and
- show me please how those cross references look like if you use __FILE__ and __MAIN__ .

thx and regards!

PS:
my neural net and my navigator both have currently about 1100-1400 lines, to be increased by further ~500 lines of header files

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Sep 23, 2008 2:28 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 24 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.