【问题标题】:Figure out function argument from custom struct?从自定义结构中找出函数参数?
【发布时间】:2010-03-28 06:18:50
【问题描述】:

我有一个将自定义结构作为参数的函数。我怎样才能弄清楚论点应该是什么?我知道这是一种日期格式...(导入到 Objective-C 的 C 库...)

结构:

typedef struct
{
    /** The number of day in the hebrew month (1..31). */
    int hd_day;
    /** The number of the hebrew month 1..14 (1 - tishre, 13 - adar 1, 14 - adar 2). */
    int hd_mon;
    /** The number of the hebrew year. */
    int hd_year;
    /** The number of the day in the month. (1..31) */
    int gd_day;
    /** The number of the month 1..12 (1 - jan). */
    int gd_mon;
    /** The number of the year. */
    int gd_year;
    /** The day of the week 1..7 (1 - sunday). */
    int hd_dw;
    /** The length of the year in days. */
    int hd_size_of_year;
    /** The week day of Hebrew new year. */
    int hd_new_year_dw;
    /** The number type of year. */
    int hd_year_type;
    /** The Julian day number */
    int hd_jd;
    /** The number of days passed since 1 tishrey */
    int hd_days;
    /** The number of weeks passed since 1 tishrey */
    int hd_weeks;
} hdate_struct;

功能:

int
hdate_get_omer_day(hdate_struct const * h)
{
    int omer_day;
    hdate_struct sixteen_nissan;

    hdate_set_hdate(&sixteen_nissan, 16, 7, h->hd_year);
    omer_day = h->hd_jd - sixteen_nissan.hd_jd + 1;

    if ((omer_day > 49) || (omer_day < 0)) 
        omer_day = 0;

    return omer_day;
}

尝试调用此函数,但不确定日期中的内容。也有将 Julian 转换为希伯来语的函数,所有函数都采用或返回相同的结构。

如何获取函数的返回值?

【问题讨论】:

  • "不确定日期是什么",你的意思是 *h 还是 sixteen_nissan
  • @David - 该函数希望我提供什么参数?我的意思是*h
  • Codewarrior - 哈哈。我知道希伯来日期是什么样子的。我想知道这个功能想要什么。转而在库中定义了一个 new_hdate() 方法。 + 1 表示幽默(u)r。

标签: objective-c c struct arguments


【解决方案1】:

看起来你想输入一个希伯来日期。因此,您必须弄清楚我们如何创建一个。尝试谷歌搜索“hdate_struct”或“convert to hdate_struct”等。

Otoh,代码 rading 函数 Counting of the Omer,函数 hdate_get_omer_day() 期间的犹太仪式如果不是在 Omer 期间,它看起来返回 zeor,如果在 Omer 的 49 天之一中返回 1 到 49(参见维基百科“40-逾越节和七七节之间的九天”)。

您可以尝试在谷歌上搜索代码来计算 Omer 日(例如“如何:制作自己的 Omer Counte”http://www.google.com.sg/url?sa=t&source=web&ct=res&cd=5&ved=0CBcQFjAE&url=http%3A%2F%2Fwww.myjewishlearning.com%2Fblog%2Fholidays%2Fhow-to-make-your-own-omer-counter%2F&rct=j&q=get+omer+Day&ei=awOvS5TvHIjGrAe_3vGmAQ&usg=AFQjCNGJh7Ydy-VkfwlyzTL_ELIkiqP25w

“剩下的留给读者练习”。

【讨论】:

  • 谢谢,知道了。 hdate_struct 内置在库中,但我找不到该结构的初始化程序。现在明白了。谢谢!并且 Omer 计数器功能似乎正在工作。
猜你喜欢
  • 2018-04-02
  • 2020-10-18
  • 1970-01-01
  • 2012-04-09
  • 2023-02-21
  • 1970-01-01
  • 2013-01-11
  • 2018-04-17
  • 1970-01-01
相关资源
最近更新 更多