小编Fra*_*ris的帖子

使用变量从bash运行IDL程序

我在IDL中编写了一个程序,用于根据命令行参数生成散点图.我可以直接在终端中成功调用程序,如下所示:

idl -e"scatterplot_1_2d_file.pro"$ infile $ outfile $ title $ xtitle $ ytitle $ xmin $ xmax $ ymin $ ymax $ timescale

其中$*引用了一些输入的字符串文字.问题是,我以为我只能输入那一行,将变量名代替文字,放入bash脚本,并生成一百万个散点图我在休息时.不幸的是,如果我这样做,我得到错误:

idl:-e选项不能用批处理文件指定

所以我的下一次尝试是尝试将这些命令写入我随后运行的IDL批处理文件.

这种尝试看起来像这样:

#!/bin/bash

indir=/path/to/indir/
outdir=/path/to/outdir/

files=`ls $indir`
batchfile=/path/to/tempbatchfile.pro

echo .r "/path/to/scatterplot_1_2d_file.pro" >> $batchfile

for file in $files
  do
  name=${file%\.*}
  echo scatterplot_1_2d_file $indir$name.txt $outdir$name.jpg $name "Gauge Precipitation (mm)" "NMQ Precipitation (mm)" "*" "*" "*" "*" 2 >> $batchfile
done #done file                                                                                                                                                                                                

echo exit >> $batchfile

idl <<EOF                                                                                                                                                                                                      
@/path/to/scatterplot_1_2d_file                                                                                                                                                                  
EOF                                                                                                                                                                                                            

rm $batchfile
Run Code Online (Sandbox Code Playgroud)

我不知道脚本生成的大部分错误是否相关,所以我只是发布开始,如果需要,我会稍后发布其余的:

[foo]$ bash script_thing.sh
IDL Version …
Run Code Online (Sandbox Code Playgroud)

bash idl-programming-language

7
推荐指数
1
解决办法
1万
查看次数

当已包含time.h标头时,取消引用指向不完整类型的指针

我正在写一个标题,timedate.h,其开头如下:

#ifndef _TIMEDATE_H_
#define _TIMEDATE_H_

int timetounixtime(int year, int month, int day, int hour, int minute, int second)
{
  struct tm *time;
  time->tm_year = year;
  time->tm_mon = month;
  time->tm_mday = day;
  time->tm_hour = hour;
  time->tm_min = minute;
  time->tm_sec = second;
  return mktime(time);
}

/*...*/

#endif
Run Code Online (Sandbox Code Playgroud)

然后将其包含在我的一个主要.c文件中,如下所示:

#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include "timedate.h"

int main(int argv, char **argc)
{
/*...*/
}
Run Code Online (Sandbox Code Playgroud)

在我看来,这应该工作,因为在调用timedate.h之前,time.h包含在主代码中.但是,当我制作时,我收到以下错误:

XXXXXXXXXX$ make
gcc file2nav.c -o file2nav
In file included from file2nav.c:4:0:
timedate.h: In function ‘timetounixtime’:
timedate.h:10:7: error: …
Run Code Online (Sandbox Code Playgroud)

c

5
推荐指数
1
解决办法
4325
查看次数

helloworld.c无法编译100多个错误

我相信我正在处理某种被破坏的库.我写了以下代码:

//helloworld.c                                                                  

#include <stdio.h>

int main()
{
  printf("Hello, world!\n");

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

并使用以下命令编译它:

gcc helloworld.c
Run Code Online (Sandbox Code Playgroud)

我得到的错误很多.这是一个示例:

/usr/include/stdio.h:510: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:514: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__wur’
/usr/include/stdio.h:517: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’
/usr/include/stdio.h:524: error: expected declaration specifiers before ‘__END_NAMESPACE_C99’
/usr/include/stdio.h:534: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:540: error: storage class specified for parameter ‘getchar’
/usr/include/stdio.h:541: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:553: error: storage class specified for …
Run Code Online (Sandbox Code Playgroud)

c configuration ubuntu-11.10

4
推荐指数
1
解决办法
2247
查看次数

使用虚函数和/或c ++中的const"丢弃限定符"错误

我研究这个问题越多,我似乎就越困惑.这是一个家庭作业问题,涉及增加我们教授给我们的代码.我知道这个问题与const关键字有关,还有一些令人困惑的新应用程序.

有一个泛型类Object,从中继承了几个子类(Sphere,Cone,Polygon).以下是Object中的类:

public: // computational members                                                
    // return t for closest intersection with ray                               
    virtual float intersect(const Ray &ray) const = 0;

    // return color for intersection at t along ray r                           
    virtual const Vec3 appearance(const World &w,
                                  const Ray &r, float t) const = 0;

    //The following function is added by me
    virtual const Vec3 normal(Vec3 p);
};
Run Code Online (Sandbox Code Playgroud)

我添加了最终功能,正常.

因此,在Sphere类中,这样实现:

const Vec3 Sphere::normal(Vec3 p)
{
  return (p - d_center).normalize();
}
Run Code Online (Sandbox Code Playgroud)

当我'make'时,我收到以下错误:

Appearance.cpp: In member function ‘const Vec3 Appearance::eval(const World&, …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance const

0
推荐指数
1
解决办法
1320
查看次数