开发者

Printf not replacing format string parameters

I'm trying to do a homework assignment involving modifying some kernel code in minix and i'm having the strangest issue i've ever seen.

I'm modifying alloc.c on the pm server (for those of you familiar with minix) and i've added a global variable to the top of the file:

PUBLIC int logging = 0;

Then later on i'm trying to read the variable in one of my functions i've added to the kernel:

PUBLIC i开发者_JAVA百科nt do_setalloc(void)
{
  printf("logging = %i\n", logging");
  return (OK);
}

I then have a test program which runs this code outside the kernel space:

int main(void)
{
  message m;
  m.m1_i1 = 1;
  m.m1_i2 = 1;
  _syscall(MM,69,&m);
  return 0;
}

This is the output when this code gets run:

logging = %i

Printf isn't actually replacing the %i formatting with the actual value of the integer, I am tearing my hair out here and this assignment is due soon! Help!


I didn't think "%i" was a valid format conversion; the most commonly-used tag to print an int is "%d". But the printf manpage I just looked at claimed %i was a synonym for %d. Perhaps the minix printf doesn't define it.


Isn't it %d for an integer in printf?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜