سؤال

هل لديها تجربة مع متناثر ؟ يبدو لي غير قادر على العثور على أي وثائق، وبالتالي فإن التحذيرات، والأخطاء التي تنتج غير واضحة بالنسبة لي. حاولت التحقق من قائمة بريدية وصفحة الرجل ولكن هناك في الحقيقة ليست من ذلك بكثير في أي منهما.

وعلى سبيل المثال، وأنا استخدم INT_MAX في واحدة من الملفات الخاصة بي. وهذا يولد خطأ (معرف غير معروف) على الرغم من انني # تضمين limits.h.

هل هناك أي مكان حيث تم شرح الأخطاء والتحذيرات؟

هل كانت مفيدة؟

المحلول

لا يقصد متناثر أن يكون الوبر، في القول. ويهدف متفرق لإنتاج شجرة تحليل من تعليمات برمجية عشوائية بحيث يمكن تحليلها.

في المثال الخاص بك، فإنك إما تحتاج إلى تعريف GNU_SOURCE (التي أعتقد أنها تدور حول __GNUC__)، الذي يعرض البتات التي تحتاج إليها في limits.h

وأود أن تجنب تحديد __GNUC__ من تلقاء نفسها، والعديد من الأشياء كما أنه ينشط قد تتصرف بطريقة غير محددة دون كل من مفاتيح الأخرى التي يتحول GNU_SOURCE على أن تكون محددة.

وجهة نظري ليست لمساعدتك الاسكواش الخطأ خطأ، ويستخدم لأؤكد من جديد أن متفرق في الغالب كمكتبة، وليس باعتبارها تقف أداة تحليل ساكنة وحدها.

من وجهة نظري نسخة من التمهيدي (غير متأكد إذا كان لدي الإصدار الحالي):

This means that a user of the library will literally just need to do

  struct string_list *filelist = NULL;
  char *file;

  action(sparse_initialize(argc, argv, filelist));

  FOR_EACH_PTR_NOTAG(filelist, file) {
    action(sparse(file));
  } END_FOR_EACH_PTR_NOTAG(file);

and he is now done - having a full C parse of the file he opened.  The
library doesn't need any more setup, and once done does not impose any
more requirements.  The user is free to do whatever he wants with the
parse tree that got built up, and needs not worry about the library ever
again.  There is no extra state, there are no parser callbacks, there is
only the parse tree that is described by the header files. The action
function takes a pointer to a symbol_list and does whatever it likes with it.

The library also contains (as an example user) a few clients that do the
preprocessing, parsing and type evaluation and just print out the
results.  These clients were done to verify and debug the library, and
also as trivial examples of what you can do with the parse tree once it
is formed, so that users can see how the tree is organized.

والعملاء وشملت المزيد من "أجنحة اختبار وظيفية وأمثلة" من أي شيء. في أداة مفيدة جدا، ولكن قد تنظر في زاوية استخدام آخر إذا كنت ترغب في توظيف ذلك. أحب ذلك لأنه لا يستخدم * يكس / البيسون، مما يجعل من الاسهل بشكل ملحوظ الإختراق.

نصائح أخرى

إذا نظرتم limits.h سترى أن يعرف INT_MAX داخل هذا #if

/* If we are not using GNU CC we have to define all the symbols ourself.
 Otherwise use gcc's definitions (see below).  */
#if !defined __GNUC__ || __GNUC__ < 2

وذلك للحصول على عمل يجب undefine __GNUC__ قبل بما في ذلك limits.h

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top