NO

Author Topic: Source file function lists  (Read 3578 times)

PhilG57

  • Guest
Source file function lists
« on: October 18, 2011, 02:39:19 PM »
I have a project with several source files.  Each of the source files has several routines (functions) within it.  For example, the file winmain.c contains WinMain and WndProc.  Other files contain multiple functions as well.

On  the source listing summary on the right hand side of the Pelles 4.50 page, some of the source files do not show all of the functions embedded in a single source file.  For example, the function "void WriteErrorMessage(char *Routine)" does not show up as a function under 'subroutines.c'.  There are other missing functions in this file and other files as well.  I've checked the prototypes and they appear to be okay.  What am I doing wrong????  Thanks.

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Source file function lists
« Reply #1 on: October 18, 2011, 05:34:12 PM »
You have a line of source code that, although it is compilable,  has some characteristic that throws the built in indexer so it doesn't parse out the information following that line of code.  To remedy the situation go to the last function in the source that is indexed (not so easy since the list is alphabetized and  your source is likely not.)  Comment it out and save the source code.  The list of functions should grow, if this is the case uncomment the method and ask yourself "what, in this method is written cleverly?"  Change it to a more text book style and save the source code.

Here's an example of clever code that will confuse the indexer:

Code: [Select]
static HBRUSH Grid_OnCtlColorStatic(HWND hwnd, HDC hdc, HWND hwndChild, INT type)
{
    //DWM 1.3: Keep the area between the description and the list refreshed
    if (NULL != g_lpInst->hwndPropDesc)
    {
        RECT rc;
        GetClientRect(hwnd, &rc);

        HDC hdc = GetDC(hwnd);
FillSolidRect(hdc,(&(RECT) { 0, g_lpInst->iVDivider - 2,
WIDTH(rc), g_lpInst->iVDivider) },GetSysColor(COLOR_BTNFACE));
        ReleaseDC(hwnd,hdc);
    }
    return FORWARD_WM_CTLCOLORSTATIC(hwnd, hdc, hwndChild, DefWindowProc);
}

Can you spot the line that is the causing the trouble?

It's this one:
Code: [Select]
FillSolidRect(hdc,(&(RECT) { 0, g_lpInst->iVDivider - 2,
WIDTH(rc), g_lpInst->iVDivider) },GetSysColor(COLOR_BTNFACE));
 

I packaged my arguments into a rectangle and passed the struct pointer on the fly.  The compiler has no problem with this but the indexer does.  I could fix this like so:

Code: [Select]
RECT rc2;
rc2.left = 0;
rc2.top = g_lpInst->iVDivider - 2;
rc2.right = WIDTH(rc);
rc2.bottom = g_lpInst->iVDivider;
FillSolidRect(hdc,&rc2,GetSysColor(COLOR_BTNFACE));
However since I am doing this several times in my code I define a macro instead:
Code: [Select]
#define MAKE_PRECT(left, top, right, bottom) \
    (&(RECT) { (left), (top), (right), (bottom) })
In the method I use it like so:
Code: [Select]
FillSolidRect(hdc,MAKE_PRECT(0, g_lpInst->iVDivider - 2,
     WIDTH(rc), g_lpInst->iVDivider),GetSysColor(COLOR_BTNFACE));
The IDE has no trouble with the syntax of this line and so the rest of the functions appear in the tree.
No one cares how much you know,
until they know how much you care.

CommonTater

  • Guest
Re: Source file function lists
« Reply #2 on: October 18, 2011, 09:55:51 PM »
Pelles 4.50

And the 5 year age of the distribution might also be a contributing issue...

Pelles C is currently at 6.50rc4... and I'd bet the indexer has had some improvement since then. 
This might be a good time to update...


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2152
Re: Source file function lists
« Reply #3 on: October 19, 2011, 10:19:11 AM »
With this code in PellesC 6.50 IDE you can see that problem.
Code: [Select]
#define WIN32_DEFAULT_LIBS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#ifdef UNICODE
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLine, int nCmdShow)
#else
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
#endif
{
return 0;
}
and this
Code: [Select]
void foo1(void);
void foo2(void);

int main(int argc, char **argv)
{
if (1 == 1)
{
#ifndef UNICODE
foo1();
}
else foo2();
#else
foo1();
}
else foo2();
#endif
return 0;
}
void foo1(void) {}
void foo2(void) {}
but this works
Code: [Select]
void foo1(void);
void foo2(void);

int main(int argc, char **argv)
{
if (1 == 1)
#ifndef UNICODE
{
foo1();
}
else foo2();
#else
{
foo1();
}
else foo2();
#endif
return 0;
}
void foo1(void) {}
void foo2(void) {}
So '{' and '}' must be paired inside #ifdef block.
« Last Edit: October 19, 2011, 12:18:08 PM by timovjl »
May the source be with you

PhilG57

  • Guest
Re: Source file function lists
« Reply #4 on: October 19, 2011, 04:22:55 PM »
DMac - thanks.  You nailed it.  For some reason, the following code was causing the problem:

      for(register DWORD i = 0; i < dwLen; i++)
      {
         BreakOutNMEA(pBuff);         /* parse for NMEA sentences one byte at a time */
      }

I now see that I have specified both "register" and "DWORD".  Removing "DWORD" did not correct the problem but removing "register" did fix it.     I don't know why, but it is indeed fixed so many thanks to you.  It really helps to be able to go to the function list and click on a subroutine to quickly jump to that section of the code.
« Last Edit: October 19, 2011, 04:24:52 PM by PhilG57 »