Pages: [1]   Go Down
Author Topic: making .cpp and .h files  (Read 1499 times)
0 Members and 1 Guest are viewing this topic.
Wyoming
Offline Offline
Newbie
*
Karma: 0
Posts: 25
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

While the Morse example shows the code and how it works, I found it lacking in creation of the actual files--.cpp first, or can the .h be done first?  The mechanics of actually doing this in the IDE aren't really there either, and this isn't obvious when you're looking at the menus and such.  I'm also guessing that these should compile(to verify the code) without being attached to a program?  That's what my logic tells me.

While I've been programming, this is a new IDE.  Browsing the forum here has helped, but not on this point.  The library tutorial kind of starts a bit after this point.

It's the simple things that kill me. smiley-sad
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46265
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use a text editor, other than the Arduino IDE to create the .h and .cpp files. Save them in the same folder as the sketch, and the next time the IDE opens that sketch it will open all the other files in that folder in separate tabs.

Generally, the .h file is created first, since it defines what needs to be coded in the .cpp file.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Try this...
  • Start the IDE
  • Locate the square with a right-pointing arrow on the top-right of the window.  It's directly across from the tabs.
  • Click the "button"; a pop-up menu should appear
  • Click [New Tab]
  • Enter a filename (e.g. "MyHeader.h") then click [OK]
Logged

Wyoming
Offline Offline
Newbie
*
Karma: 0
Posts: 25
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So how do I tell it it's a header, and should be checked as such, instead of complaining about the loop and setup functions when verifying?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46265
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The compiler knows how to handle .h files, .cpp files, and .pde files. So, you simply need to assign the correct extension.
Logged

Pages: [1]   Go Up
Jump to: