Click here to Skip to main content
15,916,180 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C and Macros Pin
Richard MacCutchan13-Feb-14 21:48
mveRichard MacCutchan13-Feb-14 21:48 
GeneralRe: C and Macros Pin
Filipe Marques14-Feb-14 0:03
Filipe Marques14-Feb-14 0:03 
GeneralRe: C and Macros Pin
Stefan_Lang14-Feb-14 2:14
Stefan_Lang14-Feb-14 2:14 
GeneralRe: C and Macros Pin
jschell14-Feb-14 10:23
jschell14-Feb-14 10:23 
GeneralRe: C and Macros Pin
Filipe Marques14-Feb-14 10:45
Filipe Marques14-Feb-14 10:45 
GeneralRe: C and Macros Pin
Stefan_Lang16-Feb-14 22:24
Stefan_Lang16-Feb-14 22:24 
GeneralRe: C and Macros Pin
Filipe Marques18-Feb-14 6:57
Filipe Marques18-Feb-14 6:57 
AnswerRe: C and Macros Pin
leon de boer5-Mar-14 1:06
leon de boer5-Mar-14 1:06 
It becomes a "depends" question and by that I mean it depends on why such deep nesting is required. To me your code looks like it either needed a variant record or simple database functions put over the top of it.

To give you the idea lets look at a simple example that would nest something like what you have. Lets say we have database of books that were linked in memory. Done in your sort of nested format to access a given line would be like this

section struct->book struct->page struct-> Line struct->actual text on that line

So you could imagine an example something like

Fiction->War and Peace->page 200->line 20->text

That structure points to the text on the 200th page, line 20 of the fictional book called "war and peace"

There is nothing wrong with that but from a programming sense it would have been much more desirable to setup a basic interface.

Define your structures Section, Book, Page, Line as per normal but make functions to do the work

book* SelectBook (book* Booklist, section, title);
page* MoveToPage (book* SelectedBook, int PageNum);
line* MoveToLine (page* SelectedPage, int LineNum);

So your code would now become something like
book* MyCurrentBook;
page* CurrentPage;
line* CurrentLine;

MyCurrentBook = SelectBook(BookList, Fiction, "War and peace");  // Select our book
Currentpage = MoveToPage(MyCurrentBook, 200); // select page 200
CurrentLine = MoveToLine(Currentpage, 20);    // select line 20

What you get for the cost of building the functions is code clarity as well as being able to contain error checks inside the functions. You can take the idea even further if you like and start writing object like code in C.

So my ultimate view of your macro depends on what your nested structure list is for and could it have been done a better way. If it couldn't then using the MACRO is perfectly fine.
GeneralRe: C and Macros Pin
Filipe Marques11-Mar-14 23:49
Filipe Marques11-Mar-14 23:49 
QuestionAdd blocker application Pin
Member 804117812-Feb-14 16:52
Member 804117812-Feb-14 16:52 
AnswerRe: Add blocker application Pin
Richard Andrew x6412-Feb-14 17:47
professionalRichard Andrew x6412-Feb-14 17:47 
GeneralRe: Add blocker application Pin
Member 804117812-Feb-14 18:20
Member 804117812-Feb-14 18:20 
AnswerRe: Add blocker application Pin
Richard Andrew x6412-Feb-14 18:22
professionalRichard Andrew x6412-Feb-14 18:22 
GeneralRe: Add blocker application Pin
Member 804117812-Feb-14 18:35
Member 804117812-Feb-14 18:35 
AnswerRe: Add blocker application Pin
jschell13-Feb-14 8:50
jschell13-Feb-14 8:50 
GeneralRe: Add blocker application Pin
Richard Deeming13-Feb-14 10:38
mveRichard Deeming13-Feb-14 10:38 
GeneralRe: Add blocker application Pin
jschell14-Feb-14 9:44
jschell14-Feb-14 9:44 
QuestionWhen clicked a button on any application, play sound Pin
cedricvictor11-Feb-14 15:48
cedricvictor11-Feb-14 15:48 
AnswerRe: When clicked a button on any application, play sound Pin
Richard MacCutchan11-Feb-14 21:27
mveRichard MacCutchan11-Feb-14 21:27 
GeneralRe: When clicked a button on any application, play sound Pin
cedricvictor16-Feb-14 16:04
cedricvictor16-Feb-14 16:04 
AnswerRe: When clicked a button on any application, play sound Pin
Malli_S11-Feb-14 21:41
Malli_S11-Feb-14 21:41 
GeneralRe: When clicked a button on any application, play sound Pin
cedricvictor16-Feb-14 16:05
cedricvictor16-Feb-14 16:05 
AnswerRe: When clicked a button on any application, play sound Pin
Malli_S16-Feb-14 19:37
Malli_S16-Feb-14 19:37 
QuestionRun an app that loaded to ram Pin
A_Fa10-Feb-14 0:32
A_Fa10-Feb-14 0:32 
AnswerRe: Run an app that loaded to ram Pin
Richard MacCutchan10-Feb-14 1:19
mveRichard MacCutchan10-Feb-14 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.