Go to Post So is it important to try? Without a doubt. Does it become frustrating to not win? Most certainly. Should you stop trying? Never! - Al Skierkiewicz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2007, 17:12
schroedinbug schroedinbug is offline
Registered User
FRC #0443
 
Join Date: Feb 2007
Location: Denver
Posts: 3
schroedinbug is an unknown quantity at this point
Variadic functions with mcc18

Has anyone used variadic functions in their FRC code? I want to have a variadic debugging function, but the function appears to get ignored when called. I know the stdarg.h is available and the code compiles, bug I get zero output from the function call (it should do a varying number of printf's, including some for general newlines, which it does not do).

Any thoughts/opinions?

If you need to see code, I can probably get a small example of what I want posted.
  #2   Spotlight this post!  
Unread 18-02-2007, 17:14
jesusescobar's Avatar
jesusescobar jesusescobar is offline
Jesus Escobar- PFTB-Programer
FRC #2066 (Pftb Of Doom)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: El Centro California
Posts: 32
jesusescobar is an unknown quantity at this point
Send a message via MSN to jesusescobar Send a message via Yahoo to jesusescobar
Re: Variadic functions with mcc18

example would help
__________________
Beware Of PFTB OF DOOM Robotics Team From EL Centro California Southwest Eagles!!!!!!!!!

http://pftbrobotics.com Our Site
  #3   Spotlight this post!  
Unread 18-02-2007, 20:50
schroedinbug schroedinbug is offline
Registered User
FRC #0443
 
Join Date: Feb 2007
Location: Denver
Posts: 3
schroedinbug is an unknown quantity at this point
Re: Variadic functions with mcc18

First, add '#include <stdarg.h>' (without quotes at the top of the user_routines.c file).

Code:
void Debug_uchar(unsigned char count,...)
{
  va_list ap; /* the list of variables - needed for variadic functions */
  unsigned char i; /* counter variable - for loop will iterate through the arguements */

  if (num_of_prog_loops == DEBUG_LOOPS)
  {
    va_start(ap, count); /* we need to initialize the arguement list */

    for (i = 0; i < count; i++)
    {
      printf("%d: %d\n", i, va_arg(ap, unsigned char);
    }

    printf("\n");

    /* num_of_prog_loops is reset at the bottom of ????? routine */
  }

  va_end(ap);
}
num_of_prog_loops is a global variable being incremented, then set to 0 after a certain number of loops
  #4   Spotlight this post!  
Unread 18-02-2007, 23:26
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Variadic functions with mcc18

Your printfs will compile but will fail to work if you don't #include <stdio.h>.
  #5   Spotlight this post!  
Unread 19-02-2007, 00:51
schroedinbug schroedinbug is offline
Registered User
FRC #0443
 
Join Date: Feb 2007
Location: Denver
Posts: 3
schroedinbug is an unknown quantity at this point
Re: Variadic functions with mcc18

Quote:
Originally Posted by Alan Anderson View Post
Your printfs will compile but will fail to work if you don't #include <stdio.h>.
This is in the user_routines.c file, which does have that defined. I'd expect the printf calls to work, since I've used them outside the function in the same source file. It seems that the program doesn't even go into the variadic function.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Known Bug With mcc18 and Wine 0.9.22 ScottWalls Programming 1 05-11-2006 15:03
Using MCC18 in a custom program EHaskins Programming 15 25-04-2006 23:35
Auton + Functions ten3brousone Programming 0 27-02-2005 20:11
Cordic functions... Zalumaskov Programming 1 13-02-2005 00:58
subs/functions maDGag Programming 2 16-02-2003 23:27


All times are GMT -5. The time now is 06:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi